【nginx】记录初接触nginx遇到的坑


host not found in upstream

问题描述

使用nginx 进行反向代理的时候,配置 proxy_pass 时使用域名,Nginx 提示

host not found in upstream

原因分析

DNS解析域名失败,ping一下域名发现ping不通

解决方案

使用Switchhosts配置域名服务器或者直接将proxy_pass配置为ip地址


nginx: [error] OpenEvent

问题描述

在重启nginx时,使用

nginx -s reload

提示

OpenEvent("Global\ngx_reload_22492") failed (2: The system cannot find the file specified)

原因分析

此时nginx并没有启动,因此没有重载到文件

解决方案

首先可以尝试关闭nginx(在nginx目录下)

.\nginx.exe -s quit

如果依然提示OpenEvent failed
那就直接启动nginx,执行

.\nginx.exe start nginx

location =/ { #alias html/agentAccount/dist/login.html; proxy_pass http://172.30.5.101:8083/login.html;
    }

nginx启动成功 报500错误

问题描述

nginx启动后 但是服务并没有启动 浏览器报500错误

原因分析

由于我自己用师姐的nginx.conf文件替换了自己的,所以在配置文件里的proxy_pass配置的还是师姐的ip地址

location =/ {
			#alias html/login.html;
            proxy_pass  http://172.30.5.101:8083/login.html;
        }

解决方案

将ip地址换为自己的ip就OK了
在控制台输入ipconfig即可查看自己的ip地址

PS C:\WINDOWS\system32> ipconfig

Windows IP 配置


以太网适配器 以太网:

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . :
   IPv4 地址 . . . . . . . . . . . . : (这里就是你的Ip地址)
   子网掩码  . . . . . . . . . . . . : 
   默认网关. . . . . . . . . . . . . : 

以太网适配器 VirtualBox Host-Only Network:

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : 
   IPv4 地址 . . . . . . . . . . . . : 
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . :

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值