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  ,浏览器查看是否能显示门户端首页即可。

  • 相关阅读:
    13 110内容回、111内容回顾、redis操作
    11 git第二部分(未完成)
    10 内容回顾和补充、分页加密
    09 深科技相关表结构 (未完成)、git
    $ python manage.py makemigrations You are trying to add a non-nullable field 'name' to course without a default; we can't do that (the database needs something to populate existing rows). Please selec
    6、DockerFile解析:三步走、保留字指令
    Linux 中各个文件夹的作用
    H.264 Profile-level-id
    H.264编码profile & level控制
    H.264分层结构与码流结构
  • 原文地址:https://www.cnblogs.com/morganlin/p/12107528.html
Copyright © 2011-2022 走看看