034 通过域名访问服务器或本地的图片资源---switchhost+nginx

1.修改host解析

2.使用Nginx代理,实现域名访问

进入Nginx的安装路径E: oolsoftware ginx-1.14.0 ginx-1.14.0conf,修改

添加如下内容:

server {
        listen       80;
        server_name  image.leyou.com;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
            root C:\Users\image;
        }
    }

范例:

重新加载Nginx

3.访问测试

浏览器输入:http://image.leyou.com/images/4/11/1524297413085.jpg

原文地址:https://www.cnblogs.com/luckyplj/p/11606294.html