Open staelche opened 7 years ago
Hi @staelche
Can you give a bit more info please, e.g. logs from MailHog or more info on the VM configuration?
When you say disconnected
- you mean the indicator in the web UI? That suggests the websocket connection isn't working - do you see any errors in your browsers javascript console or network tab?
Also do you have any proxies (e.g. nginx or haproxy) in front of it?
Without seeing any additional info, my best guess is that your VM isn't allowing the websocket connection for some reason.
I am also experiencing the same disconnected button: (unknown) WebSocket connection to 'wss://HOST/api/v2/websocket' failed: Connection closed before receiving a handshake response
. Running Mailhog behind an Apache proxy, proxy_wstunnel is enabled. Vhost attached.
I was also experiencing this while proxying from Apache (for SSL) on Centos 7.whatever. Here is a virtual host that ended up working. The key seemed to be specifying the explicit ProxyPass for the websocket path, and putting that before the HTTP ProxyPass directive.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ProxyPreserveHost On
ProxyRequests Off
ServerName mailhog.yourhost.example
SSLProxyEngine On
SSLProxyCheckPeerCN On
SSLProxyCheckPeerExpire On
ProxyPass "/api/v2/websocket" ws://127.0.0.1:8025/api/v2/websocket
ProxyPassReverse "/api/v2/websocket" ws://127.0.0.1:8025/api/v2/websocket
ProxyPass / http://127.0.0.1:8025/
ProxyPassReverse / http://127.0.0.1:8025/
<Proxy http://127.0.0.1:8025/>
AuthType Basic
AuthName "Auth Please"
AuthUserFile "/etc/mailhog/passwd"
require valid-user
</Proxy>
SSLCertificateFile /etc/letsencrypt/live/mailhog.yourhost.example/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mailhog.yourhost.example/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /etc/letsencrypt/live/mailhog.yourhost.example/chain.pem
SSLProtocol TLSv1.2
</VirtualHost>
</IfModule>
I have the an website running on Apache 2.4 at URL https://www.domain.com and MailHog UI in docker on local port 8025. Requests are reverse-proxy from URL https://www.domain.com/mail/
Here is the configuration:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
It is very important to note that without proxy_wstunnel_module websockets does not work
<VirtualHost *:443>
ServerName www.domain.com
SSLEngine On
SSLCACertificateFile "/etc/pki/tls/certs/ca-bundle.crt"
SSLOptions +StdEnvVars -ExportCertData
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.domain.com.ro/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.domain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.domain.com/chain.pem
# MailHog configuration
# Redirect /mail to /mail/
RewriteRule ^/mail$ https://%{SERVER_NAME}/mail/
# Reverse proxy
<LocationMatch /mail/>
ExpiresActive Off
ProxyPass http://127.0.0.1:8025/
ProxyPassReverse http://127.0.0.1:8025/
</LocationMatch>
# Handle websockets
<LocationMatch /mail/api/v2/websocket>
ProxyPass ws://127.0.0.1:8025/api/v2/websocket
</LocationMatch>
</VirtualHost>
Also I had to redirect /mail
to /mail
because if the I've tried https://www.domain.com/mail it returned broken CSS (404). Not sure exactly why.
I've also disabled Expires headers because my default config added a big time span, and MailHog pages were not reloading properly
I have the situation that on my development virtual machine I am always disconnected. On other servers it works pretty fine.
Do you have any explanation for this?
I am using the latest amd64 version with an up to date debian (on all machines) and start it always without any commandline options.