我需要帮助nginx配置。
在这个配置中我得到了 /svn 位置,它涉及到 apache http。
Apache 受密码保护(基本身份验证),访问时https://my.server.com/svn它显示了 apache 登录提示,但在其中,我可以看到它正在尝试访问http://127.0.0.1:81/
- 我需要隐藏此信息。
另外,当我单击“取消”按钮时,它会重定向到http://127.0.0.1:81/
显示 403。
所以我需要的是通过 https 提供一切服务,并且不向任何人展示我用于内部通信的端口。
成功登录后,它也位于 http url 和端口 81 上,但是当我手动添加 https 并删除端口 81 时,它也能工作;)
upstream subversion_hosts {
server 127.0.0.1:81;
}
server {
listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
# Set appropriately for virtual hosting and to use server_name_in_redirect
server_name server.name.com;
server_name_in_redirect off;
location / {
rewrite ^(.*) https://server.name.com$1 permanent;
}
}
server {
listen 443; ## listen for ipv4
listen [::]:443 default ipv6only=on; ## listen for ipv6
# Set appropriately for virtual hosting and to use server_name_in_redirect
server_name server.name.com;
server_name_in_redirect off;
access_log /var/log/nginx/server.name.com.access.log;
error_log /var/log/nginx/server.name.com.error.log;
include /etc/nginx/proxy_opts;
proxy_redirect off;
# Note: Adjust ssl_certificate{,_key} to custom SSL cert, if not
# using ssl-cert package
ssl on;
ssl_certificate /etc/ssl/xxxx;
ssl_certificate_key /etc/ssl/xxxx;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 60;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
# Note: Must match the prefix used in thin configuration for redmine
# or / if no prefix configured
location / {
root /usr/share/redmine/public;
error_page 404 404.html;
error_page 500 502 503 504 500.html;
try_files $uri/index.html $uri.html $uri @redmine_thin_servers;
}
location /svn {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ )
{
set $fixed_destination http$1;
}
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Destination $fixed_destination;
proxy_pass http://subversion_hosts;
}
}
}
答案1
您需要更改 proxy_redirect 变量,以便在响应中更改位置标头。