nginx反代、分发HTTPS请求

2021-01-29

...

worker_processes  2;
events {
    worker_connections  1024;
}
http {
    include       mime.types;#设定mime类型,类型由mime.type文件定义
    default_type  application/octet-stream;#默认文件类型
    keepalive_timeout  90;


    server {
        listen              443 ssl;
        server_name          {域名};
        ssl_certificate      {CRT路径};
        ssl_certificate_key  {key路径};
        location /x {
            proxy_pass http://localhost:端口1/;
        }
        location / {
            proxy_pass  http://localhost:端口2;
        }
    }
}


参考:
http://nginx.org/en/docs/http/configuring_https_servers.html

我的目的是配合frp将家里的服务放到外网上,但是又不想在服务端使用单独的端口。。。所以使用nginx分发指定的URI,通过frp代理回家。

分发URL和URI可以参考官方文档