centos 7 域名访问到端口文件

如服务器网站端口是:http://127.0.0.1:7001

nginx 可加以下配置,即可代理到7001的index.js

set $node_port 7001;    
      if ( -f $request_filename/index.html ){
          rewrite (.*) $1/index.html break;
      }
      if ( !-f $request_filename ){
          rewrite (.*) /index.js;
      }
      location = /index.js {
          proxy_http_version 1.1;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-NginX-Proxy true;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_pass http://127.0.0.1:$node_port$request_uri;
          proxy_redirect off;
      }

      location ~ /static/ {
          etag         on;
          expires      max;
      }

 

 

 

.

posted @ 2020-08-11 10:56  James2019  阅读(393)  评论(0编辑  收藏  举报