zoukankan      html  css  js  c++  java
  • Nginx监听多个端口配置实例 Linux

    开发者门户UI的访问和调用的nginx配置如下(需修改的配置文件默认在${nginxInstallPath}/conf/nginx.conf):

    server {

            listen   8010;  #端口

            server_name portal; #路径

            root  /data/ui; #解压后ui项目所在路径

            client_max_body_size 10M; #若门户端上传附件图片或资源受限时,需在此处配置文件大小的限制

            location / {

                try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404

                index  index.html index.htm;

            }

            #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件

            #因此需要rewrite到index.html中,然后交给路由在处理请求资源

            location @router {

                rewrite ^.*$ /index.html last;

            }

          location /portal/ {     #portal服务端

               proxy_pass http://10.22.0.160:30095/;

               proxy_redirect off;

           }

       }

     访问验证

    如按上述配置,访问http://nginx所在IP:8010  ,浏览器查看是否能显示门户端首页即可。

     

    综合运管UI的访问和调用的nginx配置如下(需修改的配置文件默认在${nginxInstallPath}/conf/nginx.conf):

    server {

            listen   9010;

            server_name adm;

            

            root  /data/ui; #解压后ui项目所在路径

            

            client_max_body_size 10M; #若综合运管上传附件图片或资源受限时,需在此处配置文件大小的限制

            location / {

                try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404

                index  index.html index.htm;

            }

            #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件

            #因此需要rewrite到index.html中,然后交给路由在处理请求资源

            location @router {

                rewrite ^.*$ /index.html last;

            }

          location /adm/ {      #adm服务端

               proxy_pass http://10.22.0.160:30096/;

               proxy_redirect off;

           }

          location /gateway/ {    #网关的govern端

               proxy_pass http://10.22.0.160:9099/;

               proxy_redirect off;

           }

       }

    访问验证

    如按上述配置,访问http://nginx所在IP:9010  ,浏览器查看是否能显示门户端首页即可。

  • 相关阅读:
    雷霆战机
    各种 Python 库/模块/工具
    redis
    25
    为什么Python中“2==2>1”结果为True
    thinkphp3.2路由美化,url简化
    thinkphp调整框架核心目录think的位置
    thinkphp3.2中开启静态缓存后对404页面的处理方法
    thinphp中volist嵌套循环时变量$i 被污染问题,key="k"
    thinkphp中如何是实现多表查询
  • 原文地址:https://www.cnblogs.com/morganlin/p/12107528.html
Copyright © 2011-2022 走看看