Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker installation: Monitor doesn't seem to work #74

Open
speendo opened this issue Jan 14, 2018 · 20 comments
Open

Docker installation: Monitor doesn't seem to work #74

speendo opened this issue Jan 14, 2018 · 20 comments

Comments

@speendo
Copy link

speendo commented Jan 14, 2018

I installed inbucket from docker - the Monitor doesn't seem to work. I only get the message Disconnected
screenshot-2018-1-14 inbucket monitor

@jhillyerd
Copy link
Collaborator

jhillyerd commented Jan 14, 2018

Monitor uses websockets; are you fronting Inbucket with a proxy, or doing anything else that would prevent a websocket connection from working?

You can also confirm your browser is working by hitting the demo instance: http://demo.inbucket.org/monitor

If browser is OK, take a look at browser dev tools (More tools -> Developer tools in Chrome) and see if there are any JavaScript errors, network errors.

Client side code is here: https://github.com/jhillyerd/inbucket/blob/master/themes/bootstrap/public/monitor.js

@jhillyerd
Copy link
Collaborator

FWIW, just tried this and monitor worked in my env:

docker run -it -p 10025:10025 -p 10080:10080 jhillyerd/inbucket:stable

@speendo
Copy link
Author

speendo commented Jan 14, 2018

yes, it seems to be a problem with websockets - I get a 400 - Bad request. I made a docker-compose file that looks like this:

version: '3'

volumes:
  inbucket_config:

services:
  inbucket:
	image: jhillyerd/inbucket
	ports:
	  - "5944:10080"
	  - "2500:10025"
	volumes:
	  - inbucket_config:/etc/opt
	restart: unless-stopped

so maybe it's the different ports on server and client?

@jhillyerd
Copy link
Collaborator

Just tried the above config via docker-compose -f inbucket.yml up and the monitor is working for me.

Docker version 18.01.0-ce, build 03596f5
docker-compose version 1.17.1, build unknown

Have you tried other browsers?

@speendo
Copy link
Author

speendo commented Jan 14, 2018

Hmmm, doesn't work here...

Docker version 17.12.0-ce, build c97c6d6
docker-compose version 1.18.0, build 8dd22a9

On Debian stable, these seem to be the most recent versions

@jhillyerd
Copy link
Collaborator

I wouldn't expect the docker version to play a significant role unless they were drastically different.

I'm not clear how much troubleshooting you have done so far, please be explicit. You haven't said if it works with the demo site, if you've tried other browsers, or even what browser you are using.

Is Inbucket logging anything when you make the attempt? Would be good to know if it's actually returning the 400, or of the browser is faking it.

@speendo
Copy link
Author

speendo commented Jan 16, 2018

Sorry for my late reply.

I further investigated this issue. The monitor on the monitor site works. So does the monitor on my installation, when I access it over the port that docker made available. However, it doesn't work on the URL I assigned to inbucket.

I therefore have to assume that I have to somehow enable in my apache config file:

<VirtualHost *:443>
	ServerName the.url.tld
	Header always add Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"

	ServerAdmin webmaster@localhost

	SSLEngine On
	SSLCertificateFile /etc/letsencrypt/live/the.url.tld/fullchain.pem
	    SSLCertificateKeyFile /etc/letsencrypt/live/the.url.tld/privkey.pem

	LogLevel info ssl:warn

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

	ProxyPass "/" "http://ip.ip.ip.ip:PORT/"

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

@jhillyerd
Copy link
Collaborator

Do you have https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html enabled? I haven't touched Apache in years, so I can't help much here - but this may be another one worth documenting if you can get it working. :)

@speendo
Copy link
Author

speendo commented Jan 17, 2018

I just try to debug this.

First I tried the proxy_wstunnel but I didn't succeed. Now I tried something like this

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

However, it's difficult to say whether the error comes from Apache or from Inbucket.

Is there a log in the Inbucket container and if yes, where can I find it?

Thank you!

@speendo
Copy link
Author

speendo commented Jan 17, 2018

Never mind - seems I found it already:

docker logs <container-name>

Did I mention, that I am not very experienced with docker as well? What am I doing here... 😟

@jhillyerd
Copy link
Collaborator

The start script inside the container lives here: https://github.com/jhillyerd/inbucket/blob/master/etc/docker/defaults/start-inbucket.sh

I don't see it specifying a log file, so I'm pretty sure it's logging to stdout or stderr

@speendo
Copy link
Author

speendo commented Jan 17, 2018

Yes, it is. I now see that the container is receiving the request but throws an error:

2018/01/17 20:19:46 [ERROR] HTTP error handling "/api/v1/monitor/messages": websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header
2018/01/17 20:19:46 http: multiple response.WriteHeader calls
2018/01/17 20:20:16 [ERROR] HTTP error handling "/api/v1/monitor/messages": websocket: 'Origin' header value not allowed
2018/01/17 20:20:16 http: multiple response.WriteHeader calls

Let's see if I get further...

@jhillyerd
Copy link
Collaborator

jhillyerd commented Jan 17, 2018

Inbucket Monitor is my first and only experience with websocket, so I'm not very knowledgeable on how it works. but you might be able to leverage packet capture to compare packets entering and leaving the apache proxy:

https://hub.docker.com/r/manell/wireshark/

@zaverden
Copy link

Hey guys,
I've got the same problem:

  1. Run inbucket in a docker container, map web UI to port 30025
  2. Set up apache as reverse proxy at http://inbucker.example.server.org
  3. Everything works great except monitoring (http://inbucker.example.server.org/monitoring)
  4. Monitoring works if I access it by local network IP (http://192.168.1.111:30025/monitoring)

I was able to solve it by adding ProxyPass rule for /api/v1/monitor/messages

<VirtualHost *:80>
  ProxyRequests Off
  ProxyPreserveHost On
  ProxyVia full

  ProxyHTMLInterp On
  ProxyHTMLExtended On

  <proxy *>
    Order deny,allow
    Allow from all
  </proxy>

  ProxyPass /api/v1/monitor/messages ws://localhost:30080/api/v1/monitor/messages
  ProxyPassReverse /api/v1/monitor/messages ws://localhost:30080/api/v1/monitor/messages

  ProxyPass / http://localhost:30080/
  ProxyPassReverse / http://localhost:30080/

  ServerName inbucker.example.server.org
</VirtualHost>

Apache module mod_proxy_wstunnel is enabled

@jhillyerd I think it will be helpful if settings for popular web servers (apache, nginx) are presented in a inbucket documentation

@jhillyerd
Copy link
Collaborator

The demo site is now built with docker-compose: https://github.com/jhillyerd/demo.inbucket.org

When I have time I'll play around with reverse proxy + Let's Encrypt.

@Xotabu4
Copy link

Xotabu4 commented Jan 15, 2019

@zaverden Hi! Thanks for your reply!
Can you share some details how you made it work? I didn't use proxies/apache/nginx, i just enabled port forward on my router, and having same issue as you - everything works except monitoring.

But whats super-strange - when i open montoring page at first time - it says disconnected, but when i hit F5 (just refreshing) - it becomes connected and everything works!

@jhillyerd
Copy link
Collaborator

@Xotabu4 I think you are running into #128 - which is fixed in current development tree. Beware that the latest docker build seems to be broken though - #134

@Xotabu4
Copy link

Xotabu4 commented Jan 15, 2019

@jhillyerd thanks, this is not urgent, i living with this for 2 months or so :)
Will wait for fixed latest version

@edipoReboucas
Copy link

I made works with apache proxy using a workaround for socket.io that can be found accross the web and unsetting the Origin header.

<VirtualHost 0.0.0.0:443>

    ServerName inbucket.mydomain.com

    SSLEngine On
    SSLCertificateFile "/etc/letsencrypt/live/mydomain.com/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/mydomain.com/privkey.pem"

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    ServerSignature Off
    Options FollowSymLinks
    HttpProtocolOptions Strict


  RequestHeader unset Origin  

   RewriteCond %{REQUEST_URI} ^/api/v1/monitor/messages    [NC]
   RewriteCond %{HTTP:Upgrade}  =websocket                 [NC]
   RewriteRule /(.*) ws://inbucket:9000/$1                 [P,L]

   ProxyPass / http://inbucket:9000/
   ProxyPassReverse / http://inbucket:9000/

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

@speendo
Copy link
Author

speendo commented Feb 6, 2022

I just rebuilt my routing with nginx proxy manager (https://nginxproxymanager.com/). Now it works.

From my point of view the issue is solved but it seems there are some other people who still have problems.

I can provide my solution, if anyone is interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants