nginx reverse proxy
You can use your nginx server as a reverse proxy to run notifly.
At the root of the domain
Section titled “At the root of the domain”Here’s an example configuration file if your notifly instance is running on port 1245
upstream notifly { # Set the port you are using in notifly server 127.0.0.1:1245;}
server { listen 80;
# Specify your domain / subdomain here server_name push.example.com;
location / { # We are configuring a reverse proxy proxy_pass http://notifly; proxy_http_version 1.1;
# Enabling websocket support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; proxy_redirect http:// $scheme://;
# The proxy must preserve the host, as notifly checks the host against the origin # for WebSocket connections proxy_set_header Host $http_host;
# This sets the timeout so that the websocket can stay active proxy_connect_timeout 1m; proxy_send_timeout 1m; proxy_read_timeout 1m; }}If you want to use HTTPS via nginx, leave the notifly setting NOTIFLY_SERVER_SSL_ENABLED=false and rely on nginx to encrypt your traffic just like for any other website.
On a subpath
Section titled “On a subpath”Here’s the equivalent of the above configuration example, but operating on a subpath
upstream notifly { # Set the port you are using in notifly server 192.168.178.34:8080;}
server { listen 80;
server_name localhost;
location /notifly/ { proxy_pass http://notifly; rewrite ^/notifly(/.*) $1 break; proxy_http_version 1.1;
# Enabling websocket support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; proxy_redirect http:// $scheme://;
# The proxy must preserve the host, as notifly checks the host against the origin # for WebSocket connections proxy_set_header Host $http_host;
proxy_connect_timeout 1m; proxy_send_timeout 1m; proxy_read_timeout 1m; }}