我读过像我这样的几篇文章,但似乎都没有。
我在 CentOS 7 上有一个常规的apache配置,其中有一个正常工作的网站,包括HTTP和HTTPS(certbot)。
我有另一个服务,其Web端口为`:3000,我想这样运行:
http(s)://example.com (常规网站内容)
http(s)://example.com/new_site (端口3000上的服务)
我已将网站设置为虚拟主机,并在/var/www/example.com/docroot
中设置了自定义的webroot
这是我当前的工作配置。我意识到 localhost 之间的连接不必是HTTPS,只需传入请求即可:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ProxyPass /my_site http://localhost:3000
ProxyPassReverse /my_site http://localhost:3000
ErrorLog /var/log/httpd/my_vhost_log
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</VirtualHost>
</IfModule>
我还通过启用httpd_can_network_connect SELinux boolean
清除了权限问题。
更新:
现在我的问题是上述配置覆盖了我的常规网站内容,因此,如果转到https://example.com,它将仅显示Apache欢迎页面,而不是/var/www/example.com/docroot
中的内容。
主要配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/docroot
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</VirtualHost>
</IfModule>
答案 0 :(得分:0)
In the event that anyone comes across this,
The fix is simply to add the Proxy lines to your main domain config. You only need a single config file.