nginx使用遇到的坑

 server {
        listen       80;    这里是端口 比如 服务器只开放80 
        server_name  10.10.20.127; 这里是服务器ip 或者 域名(随便任何一个域名)

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location /rzhy {   这里要注意 ,项目一定要有个区分,这个/是过滤请求的意思(我在springboot配置文件,server下面加了 context-path: /rzhy/,代表我的项目访问名称来区分)
        proxy_pass http://10.10.20.127:8082/rzhy;  这里代表实际的访问地址加端口   ,其实可以理解成  访问10.10.20.127/rzhy...这个开头的请求时,跳转为http://10.10.20.127:8082/rzhy...开头,或者说呗后者替换掉,妈的 ,要注意浏览器缓存,实在不行,nginx卸载重装,分分钟的事情
            root   html;
            index  index.html index.htm;
        }

配置好以后,在nginx根目录 输入cmd   ,
输入启动命令  和
检测配置文件命令nginx -t(防止配置文件出错)会提示什么。。ok  ....successfull表示是对的

其他的步骤网上自己找 

猜你喜欢

转载自blog.csdn.net/ajax_yan/article/details/84142531
今日推荐