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

Support for context paths #227

Closed
sean-abbott opened this issue May 26, 2015 · 14 comments
Closed

Support for context paths #227

sean-abbott opened this issue May 26, 2015 · 14 comments
Assignees
Labels

Comments

@sean-abbott
Copy link

So that you can put mailcatcher behind a reverse proxy easily. This would make it much easier to use in staging environments, or shared test environments.

@fdrouet
Copy link

fdrouet commented Oct 21, 2015

that would be great !

@sj26 sj26 added the idea label Jan 31, 2016
@sj26
Copy link
Owner

sj26 commented Jan 31, 2016

Nice idea.

@sj26 sj26 mentioned this issue Aug 10, 2016
@sj26 sj26 added the feature label Apr 4, 2017
@sj26 sj26 self-assigned this Apr 4, 2017
@sj26 sj26 removed the idea label Apr 4, 2017
@Baklap4
Copy link

Baklap4 commented Jul 14, 2017

@sj26 How far is this away from being implemented? We'd love to have this so our containers behind traefic will work nicely again!

@andrewnicols
Copy link

I've just been hitting the same issue - would be great to see a solution to this if possible!

@liamjones
Copy link

If it's helpful for anyone else; until this is complete I've been working around it with an nginx container in my docker-compose setup that rewrites the responses using the following location config:

	location /mail {
		proxy_pass http://127.0.0.1:40130/;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 1d;
		sub_filter 'src="/'     'src="/mail/';
		sub_filter 'href="/'    'href="/mail/';
		sub_filter 'url(/'      'url(/mail/';
		sub_filter '"/messages' '"/mail/messages';
		sub_filter_types text/html text/css application/javascript;
		sub_filter_once off;
	}

@andrewnicols
Copy link

andrewnicols commented Jul 29, 2017 via email

sj26 added a commit that referenced this issue Jul 31, 2017
For #227, allow specifying an http prefix to mount mailcatcher at.
@sj26
Copy link
Owner

sj26 commented Jul 31, 2017

I just added an --http-path option so you can add --http-path=/mailcatcher to mount mailcatcher with a path prefix of /mailcatcher for example. This has been released as 0.7.0.beta1, so you can gem install mailcatcher --pre. Give it a go?

@jgrasl
Copy link

jgrasl commented Oct 31, 2017

Hi @sj26 . Awesome change. One thing seems to be not working for me tough. Every link changed to /mailcatcher except the attachment link for the mail. For me it's still goes to /messages/1/ instead of /mailcatcher/messages/1/.

serg-kovalev pushed a commit to serg-kovalev/mailcatcher that referenced this issue Dec 25, 2017
For sj26#227, allow specifying an http prefix to mount mailcatcher at.
@1stone
Copy link

1stone commented May 9, 2018

I tried the new http-path option from 0.7.0.beta1.
When placed behind a reverse proxy, mapping /mailcatcher to localhost:1080/mailcatcher the UI and mail rendering looks fine.
However, I'm not able to "Clear" all messages. Clicking the button does show the confirmation popup, but if confirmed nothing happens.

@schmkr
Copy link

schmkr commented Oct 4, 2018

FYI, here's the error you get when pressing the "clear" button:

mailcatcher.js:formatted:6014 Uncaught TypeError: Failed to construct 'URL': Invalid URL

Coming from

interone-ms added a commit to interone-ms/dockerfiles that referenced this issue Jul 23, 2019
This updates mailcatcher to version 0.7.1 to allow usage of the --http-path argument (per sj26/mailcatcher#227).
@paulggapps
Copy link

Don't know if this helps, but we run mailcatcher on our staging servers and use a path instead of port 1080 i.e. domain.com/mc

We had everything working except attachments downloads, however, all other URLs were being correctly redirected to /mc/messages except attachment links.

Using the nginx config above by @liamjones we edited the following line and it now all works as expected:

sub_filter_types *;

@mullnerz
Copy link

Mailcatcher uses websockets, so for attachments to work, you also need to filter application/json content:

sub_filter_types text/html text/css application/javascript application/json;

(So no need for sub_filter_types *;)

@sj26
Copy link
Owner

sj26 commented Feb 22, 2021

--http-path in 0.7.0+ provides this feature.

@sj26 sj26 closed this as completed Feb 22, 2021
@rajeshisnepali
Copy link

	location /mail {
		proxy_pass http://127.0.0.1:40130/;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_read_timeout 1d;
		sub_filter 'src="/'     'src="/mail/';
		sub_filter 'href="/'    'href="/mail/';
		sub_filter 'url(/'      'url(/mail/';
		sub_filter '"/messages' '"/mail/messages';
		sub_filter_types text/html text/css application/javascript;
		sub_filter_once off;
	}

I got an error while running in Cloudflare with brotli compression on.

root@s02:~# nginx -t                                                                                                                                                                                 
nginx: [warn] duplicate MIME type "text/html" in /etc/nginx/sites-enabled/domain.conf:33

I had a different --http-path. From google/ngx_brotli#104 (comment), I did

  location /bin {
        proxy_pass http://127.0.0.1:1081;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 1d;
        sub_filter '"/messages' '"/bin/messages';
        sub_filter_types text/css application/javascript;
        sub_filter_once off;
 }

and was able to run properly

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

No branches or pull requests