【问题标题】:Apache ProxyPass: Page not refreshing automatically after SSL installedApache ProxyPass:安装 SSL 后页面不会自动刷新
【发布时间】:2019-08-27 01:31:39
【问题描述】:

昨天我配置了一个 Apache 反向代理,以便在 8080 端口上运行的 docker 内为 Ansible AWX 获取 SSL 证书。带有代理的 Apache 在 docker 前面,监听端口 80。 一切正常,但现在如果我要开始工作,该网站不会自行刷新。我必须手动完成才能获得结果。如果我是通过浏览服务器 ip 来做的,它工作正常。

这是我的 default.conf 的代码:

SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
<VirtualHost *:443>
ServerName example.com
ServerAdmin mail@example.com

ProxyPass / http://IP:8080/
ProxyPassReverse / http://IP:8080/
ProxyPreserveHost On
ProxyPassReverseCookiePath / /

<Proxy *>
    Order deny,allow
    Allow from all
    Allow from localhost
</Proxy>


SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>


<VirtualHost *:80>

ServerName example.com
ServerAdmin webmaster@localhost


Redirect permanent / https://example.com

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ProxyPass / ws://IP:8080/

RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} 
[END,NE,R=permanent]
</VirtualHost>

提前非常感谢! :)

【问题讨论】:

  • 您能否检查浏览器的开发者控制台是否有任何错误(在预期刷新期间)?
  • 好点,谢谢。收到 WebSocket 错误:与“wss://example.com/websocket/”的 WebSocket 连接失败:在建立连接之前 WebSocket 已关闭。
  • 太棒了,谢谢 - 它有效!刚刚将此添加到我的 default.conf RewriteEngine on RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC] RewriteRule .* ws://localhost:8080%{REQUEST_URI} [P]

标签: apache ssl ansible certbot


【解决方案1】:

谢谢你的提示,杜桑。解决了。​​

这是一个 websocket 错误,我通过将这些代码行添加到我的 default.conf 中来修复它。

    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://localhost:8080%{REQUEST_URI} [P]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 2018-04-23
    • 2013-07-28
    • 1970-01-01
    • 2012-07-21
    • 1970-01-01
    相关资源
    最近更新 更多