Last active
June 18, 2021 13:18
-
-
Save choyan/6e85354c082bcfdf49d44c629415e6ba to your computer and use it in GitHub Desktop.
Nginx configuration for domain, sub-domain and reverse proxy serup
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
# server blocks for incoming HTTP requests | |
# https://stackoverflow.com/questions/64955127/nginx-multiple-node-apps-with-multiple-subdomains | |
# https://stackoverflow.com/questions/5009324/node-js-nginx-what-now?noredirect=1&lq=1 | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name emirasgroup.com www.emirasgroup.com; | |
# redirect any HTTP request to HTTPS | |
return 301 https://$http_host$request_uri; | |
} | |
server { | |
# server block for 'sendmail.emirasgroup.com' domain | |
listen 80; | |
listen [::]:80; | |
server_name sendmail.emirasgroup.com; | |
location / { | |
proxy_pass http://localhost:4000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
server { | |
# server block for all the other requests | |
# this block will be a default server block listening on port 80 | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
# close the connection immediately | |
return 444; | |
} | |
# server blocks for incoming HTTPS requests | |
server { | |
listen [::]:443 ssl; | |
listen 443 ssl; | |
server_name emirasgroup.com www.emirasgroup.com; | |
ssl_certificate /home/ubuntu/ssl2021bundle.crt; | |
ssl_certificate_key /home/ubuntu/ssl2021.key; | |
access_log off; | |
server_tokens off; | |
error_log /tmp/log_nginx_err_wwwemirasgroupcom.log; | |
location / { | |
proxy_pass http://localhost:8000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment