Skip to content

Commit 60061c4

Browse files
committed
Rewrite apache guide
1 parent 95448d4 commit 60061c4

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

docs/proxy/guides/apache.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,22 @@ sudo a2enmod proxy_http
1616
sudo a2enmod ssl
1717
```
1818

19-
## Step 2: Update your config
19+
## Step 2: Get your snippet
20+
21+
In the "**Site Installation**" area of the "**General**" section in your [site settings](website-settings.md) you can see
22+
the snippet specific for your site. It will look similar to the following:
23+
24+
```html
25+
<script async src="https://plausible.io/js/pa-XXXXX.js"></script>
26+
<script>
27+
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
28+
plausible.init()
29+
</script>
30+
```
31+
32+
Your snippet will have a different script location than the example above. Look for the `src="https://plausible.io/js/pa-XXXXX.js"` part in your snippet - that's the personalized location for your site's script. Mark it down for subsequent steps.
33+
34+
## Step 3: Update your config
2035
```
2136
<VirtualHost *:80>
2237
ServerName website.com
@@ -26,8 +41,8 @@ sudo a2enmod ssl
2641
SSLProxyEngine on
2742
2843
<Location /js/script.js>
29-
ProxyPass https://plausible.io/js/script.js
30-
ProxyPassReverse https://plausible.io/js/script.js
44+
ProxyPass https://plausible.io/js/pa-XXXXX.js
45+
ProxyPassReverse https://plausible.io/js/pa-XXXXX.js
3146
</Location>
3247
3348
<Location /api/event>
@@ -38,16 +53,20 @@ sudo a2enmod ssl
3853
</VirtualHost>
3954
```
4055

41-
## Step 3: Adjust your deployed script
56+
Replace `https://plausible.io/js/pa-XXXXX.js` in this config with script location from step 2.
57+
58+
## Step 4: Adjust your deployed script
4259

4360
With the above config in place, you can change the script tag on your site as follows:
4461

4562
```html
46-
<script defer data-api="/api/event" data-domain="website.com" src="/js/script.js"></script>
63+
<script async src="/js/script.js"></script>
64+
<script>
65+
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
66+
plausible.init({
67+
endpoint: "/api/event"
68+
})
69+
</script>
4770
```
4871

4972
That's it! You're now using a proxy.
50-
51-
## Alternative reverse proxy written in PHP for shared hosting on Apache
52-
53-
As an alternative to the above, there's also a reverse proxy for Plausible Analytics written in PHP for shared hostings on Apache. [See details here](https://github.com/Neoflow/ReverseProxy-PlausibleAnalytics).

0 commit comments

Comments
 (0)