| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- # For more information on configuration, see:
- # * Official English Documentation: http://nginx.org/en/docs/
- # * Official Russian Documentation: http://nginx.org/ru/docs/
- ########### 每个指令必须有分号结束。#################
- worker_processes 1; # 允许生成的进程数,默认为1
- pid /var/run/nginx.pid; # 指定 Nginx 进程运行文件存放地址
- error_log /var/log/nginx/error.log;
- events {
- accept_mutex on; # 设置网络连接序列化,防止惊群现象发生,默认为on
- multi_accept on; # 设置一个进程是否同时接受多个网络连接,默认为off
- use epoll; # 事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
- worker_connections 1024; # 最大连接数,默认为512
- }
- http {
- include mime.types; # 文件扩展名与文件类型映射表
- default_type application/octet-stream; # 默认文件类型,默认为text/plain
- # 访问服务日志
- access_log on;
- sendfile on; # 允许sendfile方式传输文件,默认为off
- keepalive_timeout 75; # 连接超时时间,默认为75秒
- # 仅保留HTTP server块(删除HTTPS和域名重定向)
- server {
- listen 80; # 内网仅用80端口访问
- server_name _; # 匹配所有IP/无域名场景,替代原域名
- location / {
- root /usr/share/nginx/html/frontend/dist;
- index index.html index.htm;
- try_files $uri $uri/ /index.html; #解决页面刷新404问题
- }
- # 前端代理 - /web访问前端(http://192.168.0.247/web)
- #location / {
- # alias /usr/share/nginx/html/frontend/dist;
- # try_files $uri $uri/ /index.html; #解决页面刷新404问题
- #}
- # 小程序代理 - /app访问小程序(http://192.168.0.247/app)
- #location /app {
- # alias /usr/share/nginx/html/fastapp/dist/build/h5;
- # try_files $uri $uri/ /app/index.html; #解决页面刷新404问题
- #}
- # 后端代理 - /api/v1转发到内网后端服务
- location /api/v1 {
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_set_header X-NginX-Proxy true;
- proxy_connect_timeout 300s;
- proxy_send_timeout 300s;
- proxy_read_timeout 300s;
- # 替换为你的后端服务地址(内网IP+端口,若后端在docker内可填容器名/内网IP)
- proxy_pass http://192.168.0.247:8001;
- # WebSocket 支持(保留,不影响HTTP)
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- }
- # 错误页面配置
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- }
- }
|