nginx配置虚拟域名

2019-06-16  本文已影响0人  Roct

修改host

192.168.0.101 tomcat.paolu.com

创建nginx的配置服务

server { 
    listen 80; 
    autoindex off; 
    server_name tomcat.paolu.com; 
    access_log H:/access.log combined; 
    index index.html index.htm index.jsp index.php; 
    #error_page 404 /404.html; 
    if ( $query_string ~* ".*[\;'\<\>].*" ){ 
        return 404; 
    } 
    location / { 
        proxy_pass http://192.168.0.101:8080; 
        add_header Access-Control-Allow-Origin *; 
    } 
} 
 include vhost/*.conf;
example
 .\nginx.exe -t

输出:

nginx: the configuration file H:\nginx\nginx-1.10.2/conf/nginx.conf syntax is ok
nginx: configuration file H:\nginx\nginx-1.10.2/conf/nginx.conf test is successful

再执行

.\nginx.exe -s reload

打开tomcat.paolu.com即可访问到启动的端口为8080的tomcat服务页面。

上一篇下一篇

猜你喜欢

热点阅读