我有以下拓扑
PfSense -> Nginx -> Web 服务器,我的应用程序正在端口 8080 下监听
我的 NGINX 配置文件如下:
log_format webapp_log_format '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$http_connection" "$http_upgrade"' ;
server {
listen 80;
server_name www.example.com example.com;
## Redirect http to https
return 301 https://example.com/;
}
server {
listen 443 ssl;
server_name www.example.com example.com;
ssl_certificate /etc/certs/live/fullchain.pem;
ssl_certificate_key /etc/certs/live/privkey.key;
location / {
return 301 /webapp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
deny all;
}
location /webapp/ {
proxy_pass http://example.com:8080/webapplication/;
access_log /var/log/nginx/rap.log app_log_format;
}
}
以下是我的场景:
浏览外部https://example.com/webapp-> 显示 Web 应用没有问题
浏览外部https://example.com-> 将浏览器中的 URL 重写为https://example.com:8080/webapp(由于 8080 而无法工作)
我的配置文件有什么错误?