我有以下设置:
应用程序收听:
127.0.0.1:8069
我希望在以下位置访问服务器:
myserver.foo.com:8080
有效地使服务器访问:
https://myserver.foo.com:8443/
有效地反对代理:
127.0.0.1:8069
我有以下文件/etc/apache2/ports.conf
:
Listen 8080
<IfModule ssl_module>
Listen 8443
</IfModule>
<IfModule mod_gnutls.c>
Listen 8443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
以下配置已启用letsencrypt-ssl.conf
:
<IfModule mod_ssl.c>
<VirtualHost *:8443>
ErrorLog ${APACHE_LOG_DIR}/server.ssl.error.log
CustomLog ${APACHE_LOG_DIR}/server.ssl.access.log combined
SSLProxyEngine On
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/myserver.foo.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myserver.foo.com/privkey.pem
ProxyPass / http://127.0.0.1:8069/
ProxyPassReverse / http://127.0.0.1:8069/
</VirtualHost>
</IfModule>
以下网站也启用redirect.conf
:
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent ":8443/" https://myserver.foo.com:8443/
</VirtualHost>
但是当我尝试myserver.foo.com:8080
时,它会重定向到http://myserver.foo.com:8443/web
(当应用程序将/
重定向到/web
时),我收到以下消息:
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Apache/2.4.7 (Ubuntu) Server at myserver.foo.com Port 8443