nginx反向代理服务器域名解析,宿主机无法访问那个域名的问题
来源:2-17 nginx反向代理服务器域名解析配置实操(linux系统同学看这节)
			邵云
2018-11-11
跟着老师安装好了,nginx,然后在nginx.conf中加入了include vhost/ *.conf,然后在vhost文件夹下面,建了个www.imooc.com.conf文件,里面配置如下
server {
    default_type 'text/html';
    charset utf-8;
    listen 80;
    autoindex on;
    server_name www.imoocwlz.com;
    access_log /usr/local/nginx/logs/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[\;'\<\>].*" ){
        return 404;
    }
    location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
        deny all;
    }
    location / {
        proxy_pass http://127.0.0.1:8080;
        add_header Access-Control-Allow-Origin *;
    }
}
然后,在/etc/hosts中,加入了
192.168.83.12  www.imoocwlz.com
192.168.83.12  image.imooc.com
192.168.83.12  s.imooc.com
然后启动tomcat,启动 nginx也启动,然后在虚拟机里面,如果访问www.imoocwlz.com
是展示的tomcat的页面,宿主机访问这个网址,就不可以,求问还缺了哪些操作吗
写回答
	1回答
- 
				
				
配置host是为了让浏览器通过域名能够找到ip,浏览器在哪里就配置哪台机的host,要想通过宿主机访问,你就要配宿主机的host
232019-01-10 
相似问题