windows 下安装Nginx, 代理springboot 项目

windows 下安装Nginx, 代理springboot 项目

自己在windows服务器上安装 Nginx,并将springboot项目部署到上面,遇到问题, 通过度娘,解决后记录一下
自己也是从下面这篇文章的启发:
https://blog.csdn.net/bjash/article/details/8596554

下载nginx地址:

http://nginx.org/en/download.html

自己下载的nginx版本是windows 稳定版1.14.1, 下载解压后就算安装完成了. linux配置如下

#下面是linux中的server配置
server {
      listen       80;
       server_name  localhost;

       #charset koi8-r;

       #access_log  logs/host.access.log  main;
      #访问nginx的/, 根目录的时候, 就会访问root项目
       location / {
           root   /data/www/web/webapps/didi/dist;  
           index  index.html index.htm;
       }
       
       #配置代理, 放问/api的时候,就会访问8080的端口
       location ^~ /api/ {
               proxy_pass   http://127.0.0.1:8080;
       }
}

下面是windows 中nginx server, 配置

server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
		
		location /hospital {
            proxy_pass   http://127.0.0.1:8088/hospital/;
        }
}
备注:大坑, windows修改了配置文件后, 用nginx -s reload命令后,看不到配置后的效果,
当使用start nginx 时候,报错:nginx: [error] CreateFile() 
"D:\nginx-1.14.1/logs/nginx.pid" failed 
(2: The system cannot find the file specified)
 解决办法: nginx -s quit, 
 start nginx  
 nginx.exe -s reload
(表示重新加载配置文件启动, 注意是要在启动了之后,才能重启)
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值