使用nginx向外暴露一个端口而内部进行转发并只使用本机的多个端口

----------------使用nginx向外暴露一个端口而内部进行转发并只使用本机的多个端口------------------
此情况适合被限制只能访问唯一一个端口的场景,
例如公司限制了用户只能访问唯一的80端口。

之前使用过sslh, 都没有实现,最后尝试 nginx 可以实现。

server {
        listen       80;
        server_name  www.xuesong0323.cn;
        #access_log  logs/host.access.log  main;
        # 下面location 中可以配置多个ip 多个端口  ,或者同个ip 多个端口
        location / {
            pass_pass http://127.0.0.1:6666/; #向配哪里配哪里,后面一致就好了
            index  index.html index.php 1.php 1.html; //如果只是提供服务可以不用写具体的页面入口
        }
        location /string 
        { 
         pass_pass http://127.0.0.1:8888/string;#向配哪里配哪里,后面一致就好了 
            index index.html index.php 1.php 1.html; 
       }
        error_page   500 502 503 504  /50x.html;#错误页面
        location = /50x.html {
       #错误页面路径
            root   /home/***/;#这个一般不会改,除非你觉得自己写的的比较好看= =,我这个是改过的
        }
        location ~ \.php$ {
            root   /home/***/;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /$document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

 

你可能感兴趣的:(axios,koa2,centos,vue3)