Forked from tkc/nginx.conf with React Router and Node Reverse Proxy Server
Created
March 4, 2022 21:52
-
-
Save bilaltahseen/ccc67f6da04053ce0eb6aeb77bf3ffbf to your computer and use it in GitHub Desktop.
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 node_server { | |
server localhost:3000; | |
} | |
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
index index.html index.htm; | |
location ~* \.(?:manifest|appcache|html?|xml|json)$ { | |
expires off; | |
etag off; | |
access_log off; | |
add_header Cache-Control "max-age=86400, public, must-revalidate"; | |
} | |
location ~* \.(?:css|js)$ { | |
try_files $uri =404; | |
expires off; | |
etag off; | |
access_log off; | |
add_header Cache-Control "max-age=86400, public, must-revalidate"; | |
} | |
# Any route containing a file extension (e.g. /devicesfile.js) | |
location ~ ^.+\..+$ { | |
try_files $uri =404; | |
} | |
# Any route that doesn't have a file extension (e.g. /devices) | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
location /api/ { | |
proxy_pass http://localhost:3333; | |
proxy_set_header Host localhost; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Life Saver...