Created
September 21, 2020 12:31
-
-
Save mucahitnezir/997fb731d212c81926fee900cfa3c4c4 to your computer and use it in GitHub Desktop.
Nginx site configuration for: SPA website and Node.js proxy pass
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 { | |
listen 80; | |
listen [::]:80; | |
server_name example.com; | |
root /var/www/html; | |
index index.html; | |
location /backend/ { | |
rewrite ^/backend/(.*) /$1 break; | |
proxy_pass http://localhost:8000; # Define the address you will forward | |
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; | |
# Log | |
access_log /your/custom/logs/path/access.log; | |
error_log /your/custom/logs/path/error.log; | |
} | |
location / { | |
try_files $uri $uri/ /index.html; | |
access_log /your/custom/logs/path/access.log; | |
error_log /your/custom/logs/path/error.log; | |
} | |
} | |
# Example file path for this file: /etc/nginx/sites-available/example.com | |
# Don't forget to run this command: sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment