如何强制一个http webapp所以使用https(ssl)?

在我们的Linux服务器上,我们得到了一些sorting或Web应用程序使用http ONLY运行自己的小型networking服务器。 这意味着它本身不支持ssl。 所以即时通讯寻找一种方法来在这个小的Web服务器/ WebApp的前面打包“东西”,所以它正在对用户(必需)说HTTPS,并保持在本地(服务器内部)与WebApp交谈。

我试图find这样的事情。 但事实上,我发现很多东西涵盖了Apache,SSL和反向代理并没有真正清除事情。 我比以前更困惑了。

需要一些提示,关键字或configuration的例子来实现这一点。

谢谢

在代理stream量的web应用程序前设置一个NGINX或类似的服务器。 然后用SSL证书设置NGINX。

设置你的web应用程序在fx上运行。 端口8080并使用这段代码在NGINX中进行代理:

location / { proxy_pass http://127.0.0.1:8080/; } 

整个启用了SSL的服务器块应该是这样的:

 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; location / { proxy_pass http://127.0.0.1:8080/; } } 

Apache虚拟主机configuration示例:

 <VirtualHost *:443> ServerName example.com ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined SSLEngine on SSLCertificateFile /path/to/certificatefile SSLCertificateKeyFile /path/to/keyfile <Location /> ProxyPass http://your-webserver:8080/ ProxyPassReverse http://your-webserver:8080/ </Location> </VirtualHost> 

它没有经过testing,可能需要一些调整,但应该给你一个如何设置它的想法。

你可以尝试用apache来重写。 这个问题之前曾经有过类似的问题解释过。 https://stackoverflow.com/questions/8371/how-do-you-redirect-https-to-http