-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: serve static files using nginx web server in front of Node (#33)
This improves performance under load since 1) nginx is more performant than Node’s Express-server, 2) nginx’s performance is not impacted by Node being busy with server-side rendering tasks for dynamic content.
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
upstream nodejs { | ||
server web:4201; | ||
} | ||
|
||
server { | ||
listen 80; | ||
|
||
root /static; | ||
|
||
location / { | ||
try_files $uri sv/$uri @backend; | ||
} | ||
|
||
location @backend { | ||
proxy_pass http://nodejs; | ||
|
||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_http_version 1.1; | ||
proxy_set_header X-NginX-Proxy true; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_cache_bypass $http_upgrade; | ||
proxy_redirect off; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} |