1.原因
ip发生了变化
2.解决
用nginx转发图片的uri请求
文件
vim /etc/nginx/conf.d/mindoc.conf内容
server { listen 80; server_name morninglu.cc img.mindoc.com; location / { proxy_pass http://127.0.0.1:8181/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /files/ { alias /var/www/ngx-share/; autoindex on; } }重新加载配置
sudo nginx -s reload
3.502了
确认windows能不能ping通img.mindoc.com 如果不能在host文件下添加一行
c:\Windows\System32\driver\etc\hosts192.168.100.234 img.mindoc.com确认nginx所在的机器能不能ping通 被代理的机器
如果都能ping通 查看nginx的报错日志
/var/log/nginx/error.log最后确认
centos启用了SELinux
而默认SELinux不允许 nginx 去主动访问本地其它端口 比如8181sudo setsebool -P httpd_can_network_connect 1 sudo nginx -s reload
4.文件修改
vim /etc/sysconfig/network-scripts/ifcfg-ens32
BOOTPROTO="static" # 使用固定ip IPADDR=192.168.10.234 # ip GATEWAY=192.168.1.1 # 这里的网关要和windows网关保持一致 不然在不同ip段访问不到虚拟机重启网络
sudo systemctl restart network
文档更新时间: 2026-03-31 19:36 作者:morninglu
