configurationNginx的HTTPS

我必须设置一个反向代理redirect到一个内部networking服务器(172.16.0.115),这样我们才能允许networking外的人安全地访问networking服务器。 此服务器是在2012 R2上运行的IIS。

我在一台VM(SRVPRXY01P / 172.16.8.145)上安装了CENTOS和Nginx。

我用这个configuration成功地将httpredirect到172.16.0.115:

server { listen 80; server_name SRVPRXY01P; #root /usr/share/nginx/html; access_log /var/log/nginx/proxy-access.log combined; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://172.16.0.115/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } 

现在我必须configurationSRVPRXY01P / 172.16.8.145来redirecthttps请求。 我创build了如下的自签名证书(来自Tim Butler的NGinx Cookbook):

 openssl req -x509 -new -newkey rsa:2048 -nodes -keyout private.key -out public.pem -days 750 

我也试过了

 openssl req -x509 -new -newkey rsa:2048 -nodes -keyout private.key -out public.pem -days 750 openssl pkcs12 -inkey private.key -in public.pem -export -out certificate.p12 openssl pkcs12 -in certificate.p12 -noout -info 

我将这些文件复制到/ etc / ssl /中,并将以下内容添加到nginx.conf中

 server { listen 443 ssl; server_name SRVPRXY01P.glenoaks.edu; # root /usr/share/nginx/html; ssl_certificate "/etc/ssl/public.pem"; ssl_certificate_key "/etc/ssl/private.key"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; access_log /var/log/nginx/ssl-access.log combined; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass https://172.16.0.115/; # Also tried proxy_pass https://172.16.0.115:443/; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } 

但是,当我去https://172.16.8.145时,我的浏览器被提供了标准的Nginx欢迎页面,并且没有被redirect到https://172.16.0.115

那么我做错了什么?

  1. 我的configuration是否正确?
  2. 我是否必须在172.16.0.115上安装public.pem或certificate.p12? 当我尝试完成请求或导入时,它失败。
  3. 还有其他build议吗?