The system with an interface all uses http requests. Now I like to use ssl for URLs with login passwd. For example, when the app calls os.test.com/a/p/login, it uses https requests but other requests. I still use http requests. Now I use openssl to configure the certificate private key, etc. But now every request uses https requests, such as
server {
listen 443;
server_name os.test.com;
ssl on;
ssl_certificate /etc/ngx/conf.d/server.crt;
ssl_certificate_key /etc/ngx/conf.d/server.key;
location / {
proxy_pass http://127.0.0.1:9988;
}
}
How should I modify this
阿神2017-05-16 17:23:05
You have to write it separately. First create a server to specifically handle https requests, and then reverse proxy it based on the URL. Here is the code:
server {
listen 443;
server_name os.test.com;
location / {
}
location ~* .(login|passwd)$ {
proxy_pass http://127.0.0.1:9999
}
}
server{
listen 9999
server_name 127.0.0.1
ssl on;
ssl_certificate /etc/ngx/conf.d/server.crt;
ssl_certificate_key /etc/ngx/conf.d/server.key;
location / {
}
}
黄舟2017-05-16 17:23:05
# http
server {
listen 80;
location /login {
rewrite ^ https://$host$request_uri permanent;
}
}
# https
server {
listen 443;
}