[英]Apache redirect to https://www and then proxy to localhost
我有一个在localhost:8180
上运行的node.js应用程序。
我希望只能通过https://www.example.com从网络上访问该应用程序。
目标是将所有前往http://example.com
: http://www.example.com
https://example.com
http://example.com
流量重定向到https://www.example.com
。
我可以访问Plesk面板v12.5.30。 在此面板中,我可以为http和https请求配置单独的.htaccess规则。 该面板如下所示:
我可以使用此面板实现目标吗?
我已经尝试过以下针对http和https的规则,但是出现代理错误。
http
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com$1 [L,R=301]`
https
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://localhost:8180$1 [P]
ProxyPassReverse / http://localhost:8180/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.