nginx 踩坑日记

启动报错.

  1. 不建议双击nginx.exe 建议使用命令行到该目录后 start nginx.exe .
  2. 程序目录全英文.
  3. 前端程序放在 html目录(存在index.html的目录, 老版本是www目录)

前端转发到后端失败.

1
2
3
4
5
6
7
8
9
10
11
12
13
server {
listen 8888; # 表示监听8888端口 作为总入口
location /{ # 表示不带任何字符 则进入前端项目
root html;
index index.html index.htm;
}

location /api/{ # 表示url带 api 则转发到下面的地址
proxy_pass http://127.0.0.1:8081/; # 注意最后一个斜线 折磨我好久
}

}

nginx 配置的ip无效

         location /api {
            proxy_pass http://127.0.0.1:8088/
        }
        
         location /api {
            proxy_pass http://127.0.0.1:8088/api/;
        }