我需要帮助我的nginxconfiguration。
在这个configuration我有/ svn的位置,来到Apache的HTTP。
Apache是密码保护(基本authentication)当访问https://my.server.com/svn它显示了Apachelogin提示,但在它,我可以看到它试图访问http://127.0.0.1:81/ – 我需要隐藏这些信息。
另外,当我点击取消button,它会redirect到http://127.0.0.1:81/显示403。
所以我需要的是通过https服务,而不是向任何人展示我用于内部通信的端口。
成功login后,它也是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; } } }
Nginx的proxy_redirect
您需要更改proxy_redirectvariables,以便在响应中更改位置标头。