作者:sdfasdfqg | 来源:互联网 | 2023-01-31 15:35
我有一个Nginx作为Nexus存储库的SSL终止反向代理.
这是配置:
server {
server_name nexus.example.com;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
client_max_body_size 1G;
location / {
if ($http_user_agent ~* docker) {
proxy_pass http://127.0.0.1:8082;
}
proxy_pass http://127.0.0.1:8081;
proxy_COOKIE_path / "/; secure; HttpOnly";
proxy_set_header Host $http_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-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
access_log /var/log/nginx/nexus_access.log;
error_log /var/log/nginx/nexus_error.log;
}
这没关系,工作正常.但是,我想在另一个端口公开Nginx,比方说10000.如果我更改配置并重新启动Nginx和Nexus,每当我访问时都会nexus.example.com:10000
遇到多个错误,因为浏览器正在对资源进行请求https://nexus.example.com
(没有端口) .
我认为这可能是一个缓存问题,所以我尝试了隐身模式,但它也没有用.试过一个全新的虚拟机,同样的问题,所以我放弃了缓存问题.
如果我直接在nexus.example.com:8081上公开Nexus,它也能正常工作.
可能有什么问题?
我尝试了以下解决方法,但是虽然我能够访问Nexus首页,但我无法登录.
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;
location / {
return 301 https://$host:10000$request_uri;
}
}
Ying Yi..
6
我遇到了同样的问题.改变proxy_set_header Host $host;
来
proxy_set_header Host $host:$server_port;
解决它
1> Ying Yi..:
我遇到了同样的问题.改变proxy_set_header Host $host;
来
proxy_set_header Host $host:$server_port;
解决它