版权声明:博主原创文章,欢迎大家转载! https://blog.csdn.net/happycxz/article/details/77568613
upstream tomcat_test {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name YOUR_API_DOMAIN_HERE;
if ($http_host !~ "^YOUR_API_DOMAIN_HERE$") {
rewrite ^(.*) http://YOUR_API_DOMAIN_HERE$1 last;
}
### https://YOUR_API_DOMAIN_HERE/test/xxxx/xx?xx=xx
location /test/ {
proxy_pass http://tomcat_test/;
#proxy_cookie_path / /test/;
#proxy_redirect http://tomcat_test/ http://YOUR_API_DOMAIN_HERE/test/;
proxy_set_header Host $host;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/YOUR_API_DOMAIN_SSL_PATH_HERE/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/YOUR_API_DOMAIN_SSL_PATH_HERE/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf;
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
# Redirect non-https traffic to https
# if ($scheme != "https") {
# return 301 https://$host$request_uri;
# } # managed by Certbot
}