diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..1de40ac --- /dev/null +++ b/nginx.conf @@ -0,0 +1,64 @@ +# 设置运行 Nginx 的用户 +user nginx; + +# 启动的 worker 进程数量,一般设置为 auto,Nginx 会自动根据 CPU 数量设置合适的数量 +worker_processes auto; + +# 错误日志路径和级别 +error_log /var/log/nginx/error.log warn; + +# PID 文件路径 +pid /var/run/nginx.pid; + +# 定义全局事件 +events { + # 最大连接数 + worker_connections 1024; +} + +# 定义 HTTP 服务器 +http { + # 包含 MIME 类型的文件 + include /etc/nginx/mime.types; + # 默认 MIME 类型 + default_type application/octet-stream; + + # 自定义的 Nginx 配置 + server { + # 监听的端口 + listen 80; + # 服务器名称 + server_name localhost; + + location / { + # 网站根目录,此处使用容器内的路径 + root /usr/share/nginx/html; + # 默认首页 + index index.html; + # 尝试从磁盘找到请求的文件,如果不存在则跳转到 index.html + try_files $uri $uri/ /index.html; + } + + # location ^~ /api/ { + # 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-NginX-Proxy true; + # #下面两个必须设置,请求头设置为ws请求方式 + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection "upgrade"; + # proxy_pass http://192.168.41.101:28003/; + # } + + # location /api/login/ { + # # rewrite ^/wsUrl/(.*)$ /$1 break; #拦截标识去除 + # proxy_pass http://192.168.41.101:28003/; #这里是http不是ws,不用怀疑,代理的ip和port写ws访问的实际地址 + # proxy_http_version 1.1; #这里必须使用http 1.1 + # #下面两个必须设置,请求头设置为ws请求方式 + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection "upgrade"; + # } + + } +} + \ No newline at end of file