nginx遇到的坑

1.当你本地web项目通过tomcat启动时,如果端口是8080,将会和nginx冲突,不然你访问localhost:8080会报404;不过访问localhost是可以的。

解决方法是将tomcat的端口号改掉,或者该nginx的端口号,这样你访问localhost:8080才会出现nginx的欢迎页面。

2.想访问本地静态页面时,配置如下

     location /site/fortune/ {
        root F:/wds/nginx-1.12.2/nginx-1.12.2/html/;
        rewrite ^/fortune/(.*)$ /fortune/$1 break;

        }

详解:访问http://localhost:8080/site/fortune/fortune.html时,nginx就会转发到

F:/wds/nginx-1.12.2/nginx-1.12.2/html/site/fortune/fortune.html

3.web服务的端口是8087  但是nginx文件的服务的端口是8080,相当于把2个服务都起来了,页面上拼接url,例如:

style="background: url(${fileServerUrl}/${list.imgUrl}) no-repeat center center;"



备注,当你发现你配置的文件路径访问不到,多看看log文件中的错误日志。。。。。。。。。。。。。。。。。。。。。。。。。

猜你喜欢

转载自blog.csdn.net/wudiansheng/article/details/79912866
今日推荐