Invalid redirect when accessing ATLAS on a URL not ending in a trailing slash
See original GitHub issueExpected behavior
When running the atlas container exposed on a port other than 8080 or when accessing the container from a reverse proxy and the /atlas
URL does not end in a trailing slash, one should still be able to see the ATLAS UI.
Actual behavior
The nginx server responds with a redirect to the server host and port with the trailing slash added to the URL. This seems to be a common issue: https://serverfault.com/questions/739498/nginx-rewrite-on-docker-machine-when-host-port-container-port
I was able to resolve it by using the following /etc/nginx/default.conf:
server {
listen 8080;
root /usr/share/nginx/html;
location ~ ^.*[^/]$ {
try_files $uri @rewrite;
}
location @rewrite {
return 302 $scheme://$http_host$uri/; # <- this uses the request header ('Host:') to determine the hostname+port
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
If it seems reasonable, I can create a PR for this.
Steps to reproduce behavior
docker run --rm -it -p 9090:8080 ohdsi/atlas:2.10.1
curl -vvv localhost:9090/atlas
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9090 (#0)
> GET /atlas HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.20.1
< Date: Fri, 26 Nov 2021 11:09:30 GMT
< Content-Type: text/html
< Content-Length: 169
< Location: http://localhost:8080/atlas/ # <---- see here
< Connection: keep-alive
<
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>
* Connection #0 to host localhost left intact
- thus this would redirect to localhost on port 8080 but the container is exposed on port 9090
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to fix internal redirects from trailing slash mismatch?
This issue means that the one URL on your site is redirected to another internal URL. The presence/absence of a trailing slash is...
Read more >How to force https, www and a trailing slash with one redirect
The right way is to make the .htaccess check for the / then check for www. and https:// . If any of our...
Read more >Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >Wrong repo url if you define a "Base URL" with a trailing slash
If you define a "Base URL" with a trailing slash in the server settings section like 'http://nexushost/nexus/' you cannot browse in the repo ......
Read more >Redirect to URL with trailing slash doesn't occur in Websphere ...
Then I deployed the same application on WAS 8.5.5. Trying to access war module with the same URL localhost:9080/Foo/Bar (without trailing slash) and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@anthonysena Ah sorry, to clarify: it would just mean adding a custom nginx.conf to the container when it is build - I’ll go ahead and create a PR.
Thanks for your reply @chgl