我无法使用SSL将nginx服务器配置为同一IP地址下不同位置的反向代理。
这是我的Nginx配置文件:
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 default_server;
server_name example.com;
ssl_certificate /etc/ssl/private/app1.crt;
ssl_certificate_key /etc/ssl/private/app1.key;
ssl_certificate /etc/ssl/private/app2.crt;
ssl_certificate_key /etc/ssl/private/app2.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
#App1
location ^~ / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://10.0.x.x/;
}
#App2
location ^~ /subdomain{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://10.0.x.x/;
}
}
以上代码适用于第一个位置“ https://example.com/”,但不适用于“ https://example.com/subdomain”。
任何人都可以提供有关如何正确执行此操作的指导吗?