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
Reverse Proxy into Docker containers with Caddy vs Nginx #205
Comments
Hey Joel, thanks for looking into this. You say that the browser is being redirected when you use the proxy directive? As in, the browser is getting a 3xx HTTP status code? |
I guess im late to the party... Actually nginx modifies the Location header only. I already hardcoded a fix for myself into caddy, but i have absolutely no idea how i could contribute with good code though. I just added some lines here:
This fixes it for me, but i just came to the conclusion for that ugly fix after trying to figure out how it is supposed and failing after a few hours. Hope it helps. |
@joelchen It doesn't work :( |
Is it something can be fixed by adding |
That suggestion should work, so, closing. Unless there's anything else on this. |
Here is my experiment of reverse proxy into Docker containers with Caddy vs Nginx.
Docker gateway IP of 172.17.42.1 is used to achieve it on Nginx, rather than linking other Docker containers with Caddy container, because by linking containers it creates dependency/coupling, if one of my Docker containers crashes, Caddy container will fail to start, and I would like my reverse proxy to be up regardless of the health of my Docker containers.
Here is a sample of Nginx configuration:
This Nginx configuration works for all of requests starting with /webapp. I tried to replicate it on Caddy, and this is the best configuration I could formulate:
This Caddy configuration works for some requests like http://example.com/webapp/ and http://example.com/webapp/home/index.jsp. However, it redirects browser to http://172.17.42.1:8080/webapp/ when the request is http://example.com/webapp, and redirects browser to http://172.17.42.1:8080/webapp/home/login.jsp when JavaScript
document.myform.submit()
is called on<form name="myform" action='/webapp/home/login.jsp' method=POST>
. Instead of form submission, request using JavaScript XMLHttpRequest object'sopen('POST', 'http://' + window.location.host +'/webapp/home/login.jsp', true)
followed bysend()
works.I know that reverse proxy into Docker containers is not officially supported in Caddy when I discovered this issue, but I hope that the results of my experiment will move things forward.
Warmest Regards,
Joel
The text was updated successfully, but these errors were encountered: