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 [2020/02/27 14:21] kalenpw [Nginx] |
development:deploy:nginx [2021/07/06 09:48] (current) kalenpw |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Nginx ====== | ====== Nginx ====== | ||
- | :!: These are messy and need cleaned up\\ | + | |
- | FIXME add example configs | + | |
---- | ---- | ||
===== Example Server Blocks ===== | ===== Example Server Blocks ===== | ||
- | ** Laravel ** | + | Note: These are messy and need cleaned up. Don't blindly copy-paste may be errors. |
+ | | ||
+ | | ||
+ | * [[.nginx: react | React ]] | ||
+ | * [[.nginx : rocketchat | Rocket.Chat ]] | ||
+ | * [[.nginx: vue | Vue ]] | ||
+ | |||
+ | ---- | ||
+ | ===== Config ===== | ||
+ | ** Caching | ||
<code nginx> | <code nginx> | ||
- | server { | + | location /_assets |
- | listen 80; | + | |
- | server_name www.switchart.tk switchart.tk; | + | |
- | + | ||
- | root / | + | |
- | index index.php index.html; | + | |
- | + | ||
- | | + | |
- | | + | |
- | } | + | |
- | + | ||
- | location ~ \.php$ { | + | |
- | | + | |
- | fastcgi_pass unix:/ | + | |
- | fastcgi_index index.php; | + | |
- | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | + | |
- | include fastcgi_params; | + | |
- | } | + | |
- | + | ||
- | location ~ / | + | |
- | deny all; | + | |
- | } | + | |
- | error_page 404 /404.html; | + | |
} | } | ||
</ | </ | ||
- | ** React ** | + | |
+ | ---- | ||
+ | **http2** \\ | ||
+ | Only works with TLS and modern browsers (though 95%+ usage) | ||
<code nginx> | <code nginx> | ||
server { | server { | ||
- | listen | + | listen |
- | | + | ... |
+ | } | ||
+ | </ | ||
- | root / | + | ---- |
- | index index.php index.html; | + | **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 / { | location / { | ||
- | | + | |
} | } | ||
- | |||
- | location ~ \.php$ { | ||
- | fastcgi_pass unix:/ | ||
- | fastcgi_index index.php; | ||
- | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | ||
- | include fastcgi_params; | ||
- | } | ||
- | |||
- | location ~ / | ||
- | deny all; | ||
- | } | ||
- | error_page 404 /404.html; | ||
- | |||
- | listen 443 ssl; # managed by Certbot | ||
- | ssl_certificate / | ||
- | ssl_certificate_key / | ||
- | include / | ||
- | ssl_dhparam / | ||
} | } | ||
- | </code> | + | </file> |
- | ** Vue ** | + | ---- |
- | <code nginx> | + | |
- | server { | + | |
- | listen 80; | + | |
- | listen 443 ssl; # managed by Certbot | + | |
- | server_name www.kalen.pw kalen.pw; | + | |
- | | + | ** Redirect all URLs to root** \\ |
- | index index.php index.html; | + | Used, for example, on kalen.pw |
- | + | <code nginx> | |
- | | + | location / { |
- | | + | |
- | fastcgi_pass unix:/ | + | |
} | } | ||
- | |||
- | error_page 404 /404.html; | ||
- | ssl_certificate / | ||
- | ssl_certificate_key / | ||
- | include / | ||
- | |||
- | #if ($scheme != " | ||
- | # return 301 https:// | ||
- | #} # managed by Certbot | ||
} | } | ||
</ | </ | ||
+ | ---- | ||
+ |