Nginx config:修订间差异
创建页面,内容为“ =Configuration= ==Serve React== ==Reverse proxy== Category:Linux/Unix” |
标签:2017版源代码编辑 |
||
(未显示同一用户的2个中间版本) | |||
第2行: | 第2行: | ||
=Configuration= | =Configuration= | ||
==Serve React== | ==Serve React== | ||
Note: | |||
* Solve browser route 404:<ref>https://stackoverflow.com/questions/45598779/react-router-browserrouter-leads-to-404-not-found-nginx-error-when-going-to</ref> | |||
<syntaxhighlight lang="nginx"> | |||
server { | |||
root /var/www/html; | |||
server_name yai.ink; | |||
location / { | |||
try_files $uri $uri/ /index.html; | |||
} | |||
} | |||
</syntaxhighlight> | |||
==Reverse proxy== | ==Reverse proxy== | ||
Note: be careful that the backend should also use correct config. | |||
<syntaxhighlight lang="nginx"> | |||
server { | |||
index index.html index.htm index.nginx-debian.html; | |||
server_name yai.ink; | |||
location / { | |||
proxy_pass http://localhost:8000; | |||
} | |||
} | |||
</syntaxhighlight> | |||
[[Category:Linux/Unix]] | [[Category:Linux/Unix]] |
2024年12月7日 (六) 03:21的最新版本
Configuration
Serve React
Note:
- Solve browser route 404:[1]
server {
root /var/www/html;
server_name yai.ink;
location / {
try_files $uri $uri/ /index.html;
}
}
Reverse proxy
Note: be careful that the backend should also use correct config.
server {
index index.html index.htm index.nginx-debian.html;
server_name yai.ink;
location / {
proxy_pass http://localhost:8000;
}
}