-
Notifications
You must be signed in to change notification settings - Fork 0
Nginx configuration
Sven Pachnit edited this page Jan 18, 2019
·
2 revisions
It's recommended to let a proper webserver do the static asset delivery of the client files.
If you choose to use nginx you can work off this template.
- don't forget to change variables (e.g.
[_!_DESC(defaultOrExample)_!_]
) - the websocket path is
/cable
and must upgrade connection
upstream synctube_server {
server localhost:[_!_SYNCTUBE_PORT(1337)_!_] fail_timeout=0;
}
# redirect http to https
server {
server_name [_!_HOSTNAME(sync.example.com)_!_];
listen 80;
listen [::]:80;
location / {
rewrite ^ https://$server_name$request_uri? permanent;
}
}
server {
server_name [_!_HOSTNAME(sync.example.com)_!_];
listen 443 ssl;
listen [::]:443 ssl;
ssl on;
ssl_certificate [_!_SSL_CERT(/etc/nginx/ssl/fullchain.pem)_!_];
ssl_certificate_key [_!_SSL_KEY(/etc/nginx/ssl/key.pem)_!_];
root [_!_WEB_ROOT(/home/www/synctube_node/www)_!_];
# optional access log
#access_log /var/log/nginx/synctube.access.log combined;
# websocket
location = /cable {
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 $scheme;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 36000s; ## Timeout after 10 hours
proxy_redirect off;
proxy_pass http://synctube_server;
}
}
upstream synctube_server {
server localhost:[_!_SYNCTUBE_PORT(1337)_!_] fail_timeout=0;
}
# redirect http to https
server {
server_name [_!_HOSTNAME(sync.example.com)_!_];
listen 80;
listen [::]:80;
root [_!_WEB_ROOT(/home/www/synctube_node/www)_!_];
# optional access log
#access_log /var/log/nginx/synctube.access.log combined;
# websocket
location = /cable {
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 $scheme;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 36000s; ## Timeout after 10 hours
proxy_redirect off;
proxy_pass http://synctube_server;
}
}