Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
development:deploy:nginx [2021/07/06 09:30] kalenpw |
development:deploy:nginx [2021/07/06 09:48] (current) kalenpw |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Nginx ====== | ====== Nginx ====== | ||
| - | * [[.nginx : config | Config ]] | ||
| - | |||
| ---- | ---- | ||
| ===== Example Server Blocks ===== | ===== Example Server Blocks ===== | ||
| + | Note: These are messy and need cleaned up. Don't blindly copy-paste may be errors. | ||
| * [[.nginx : dokuwiki | Dokuwiki ]] | * [[.nginx : dokuwiki | Dokuwiki ]] | ||
| * [[.nginx: laravel | Laravel ]] | * [[.nginx: laravel | Laravel ]] | ||
| Line 11: | Line 10: | ||
| * [[.nginx: vue | Vue ]] | * [[.nginx: vue | Vue ]] | ||
| - | Note: These are messy and need cleaned up. Don't blindly copy-paste may be errors.\\ | ||
| ---- | ---- | ||
| - | ===== Example Server Blocks | + | ===== Config |
| + | ** Caching ** | ||
| + | <code nginx> | ||
| + | location /_assets { | ||
| + | expires 30d; | ||
| + | root / | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | **http2** \\ | ||
| + | Only works with TLS and modern browsers (though 95%+ usage) | ||
| + | <code nginx> | ||
| + | server { | ||
| + | listen 443 http2 ssl; | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | **Reverse Proxy** \\ | ||
| + | Useful for services that run on abnormal ports, but you want to have clean urls to access them | ||
| + | |||
| + | <file nginx reverse_proxy.conf> | ||
| + | server { | ||
| + | server_name example.domain.com; | ||
| + | location / { | ||
| + | proxy_pass http:// | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||
| + | |||
| + | ** Redirect all URLs to root** \\ | ||
| + | Used, for example, on kalen.pw so any non-found files are redirected to the homepage (as opposed to serving a 404) | ||
| + | <code nginx> | ||
| + | location / { | ||
| + | if (!-e $request_filename) { | ||
| + | rewrite ^ / permanent; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ---- | ||