-
Notifications
You must be signed in to change notification settings - Fork 8
Deployment with nginx
It is strongly recommended to deploy WT1 behind a reverse-proxy server. Deploying behind a reverse-proxy brings the following advantages:
- Only the minimal set of URIs required for the tracker functionality is exposed to the public. See Security considerations
- The reverse proxy will offload the management of client connections from the servlet container, and only keep a reduced number of persistent connections to the servlet container.
NGInx is a popular and lightweight web server, which works very well as a reverse proxy.
In this scenario, nginx will receive the incoming connections from the tracking JS snippet or the API clients and forward them to the Web application backend.
- The tracker is running on the same machine as the nginx host, on port 8080, deployed on context path /wt1/
- The clients and tracking JS snippet want to access the tracker on http://tracker.mycompany.com/public/p.gif and http://tracker.mycompany.com/public/events
- The tracking JS snippet is served by nginx, at address http://tracker.mycompany.com/track.js
aptitude install nginx
yum install nginx
You can simply follow the instructions in the Installing as a standalone Web application.
Find the server
block of your nginx configuration. In Debian and Ubuntu, it's located in /etc/nginx/sites-available/default
or another virtual host.
Store the tracking JS (and other static contents as needed) in a suitable directory, e.g. /data/wt1/htdocs
Put something like that in the server block
server {
# It's 2013, listen to IPv4 and IPv6
listen 80;
listen [::]:80;
server_name tracker.mycompany.com
# Static files including tracker script
root /data/wt1/htdocs;
expires 2h;
# Forward the public APIs to the tracker
location /public {
proxy_pass http://localhost:8080/wt1/public;
expires off;
}
# Reverse proxy configuration
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
That's it.
Just reload your nginx configuration: /etc/init.d/nginx
reload
Point your browser to http://tracker.mycompany.com/public/p.gif and you should get the tracking pixel.