Youtrack with NGINX in subdirectory
Hi,
I am having trouble getting youtrack to run in a subdirectory (`$DOMAIN/youtrack`) behind a NGINX reverse proxy with docker.
I've read the Reverse Proxy Documentation and all posts about NGINX and subdirectory deployments in this forum.
I can get to the installation wizard but cannot succeed to set the `base_url` and the NGINX location so that everything works.
Here's the setup:
- Youtrack should be running on https://$DOMAIN/youtrack/
- The listen port on the host should be 7200 (mapped as 7200:8080 in the container)
- We have several services running in a subpath with NGINX and I've tried all rewrite and `proxy_pass` configurations I know of without success
This post comes close but does not provide a final solution.
The `location` block looks as follows (with `172.17.0.1` being the docker0 gateway):
```
location /youtrack/ {
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffers 8 64k;
proxy_busy_buffers_size 128k;
proxy_buffer_size 64k;
client_max_body_size 10m;
proxy_http_version 1.1;
proxy_pass http://172.17.0.1:7200;
}
```
```
location /api/eventSourceBus {
proxy_cache off;
proxy_buffering off;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
proxy_set_header Connection '';
chunked_transfer_encoding off;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_pass http://172.17.0.1:7200;
}
```
Please sign in to leave a comment.
Hi!
I'm Sergey from the Youtrack team.
In this case, Youtrack should be deployed with the same path as you'd like to proxy it with. Consequently, Youtrack should be deployed at http://172.17.0.1:7200/youtrack (the Base URL should be set to it). Then proxy_pass directive should set to http://172.17.0.1:7200/youtrack as well.
Please adjust your configuration and let me know how it goes.
Hi Sergey!
Thanks - that did it!
First time I come across a case where a base URL needs to be set to the docker0 gateway :)
Maybe such a dedicated example could help making the NGINX docs even better.
Thanks for your reply!
Indeed, including this information in the documentation would be helpful. I've already submitted a task for our content writers. Thank you for bringing it to our attention.
>URL needs to be set to the docker0 gateway
In general, that's not really about Docker. The main idea is that the URI that you map the location to must match the URI that you have in the proxy_pass directive regardless of your type of installation.
I agree its not about the `docker0` gateway per se, but in this specific example (docker + nginx) this hint could be helpful.
Often enough (in other services) the "base url" of a service needs to be set to the public domain of that service and not the "passthrough" internal connection :)
So yeah, maybe even one small sentence ala "in a docker + nginx scenario, ensure that the base url is set to whatever your docker gateway/passthrough connection is" (or similar) :)
I am sure you will find a more appropriate wording. Thanks for the quick replies!
Thanks for your reply. I see what you mean. Also, I should note that in your case, replacing http://172.17.0.1:7200/youtrack with https://$DOMAIN/youtrack/ in all the places would also work.
Either way, hope that the documentation will be adjusted soon to cover such cases.
reverse proxy according to docs not working for me, unless I add a slash at the end
(Nginx 1.18)
location /ytrk01/ {
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffers 8 64k;
proxy_busy_buffers_size 128k;
proxy_buffer_size 64k;
client_max_body_size 10m;
proxy_http_version 1.1;
proxy_pass http://192.168.91.20:8080/ytrk01/;
}
Jb-account1 Thank you for noticing! Indeed, there should be a slash. We'll change the documentation accordingly.