Last active
February 22, 2021 13:21
-
-
Save aliemre/0456fa61ae0ec43627342b9a55f3054a to your computer and use it in GitHub Desktop.
Sails.js Socket configuration for Nginx 1.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream sails { | |
ip_hash; | |
keepalive 64; | |
server 127.0.0.1:1400 max_fails=3 fail_timeout=10s; | |
server 127.0.0.1:1400 max_fails=3 fail_timeout=10s; | |
} | |
server { | |
root /var/www/erp; | |
# Add index.php to the list if you are using PHP | |
index index.html index.htm index.nginx-debian.html; | |
server_name erp.domain.com; | |
# Sails App | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
#try_files $uri $uri/ =404; | |
proxy_pass http://sails/; | |
} | |
# Socket.io | |
location /socket.io/ { | |
proxy_http_version 1.1; | |
proxy_pass http://sails/socket.io/; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header Access-Control-Allow-Origin *; | |
proxy_read_timeout 900; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/erp.domain.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/erp.domain.com/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
if ($host = erp.domain.com) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name erp.domain.com; | |
return 404; # managed by Certbot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment