Comments (4)
@polarathene , much thanks for looking at this. Looks like absolute_redirect
is indeed the ticket. I've just pushed a PR that turns that off, and turns port_in_redirect
on. That appears to work w/o modifying anything else.
Not sure what the side-effects are of these two settings (I see chatter that they are used when you put a proxy in front of nginx), but the fix does make my site work.
from gatsby-docker.
In the reproduction repo you provided me via the Discord group, I was able to confirm the issue.
http://localhost:8001/k8s
would redirect to a trailing slash with the port removed. If you gave the trailing slash path from the start(http://localhost:8001/k8s/
, this seems to work properly without redirecting to the dropped port.
If the setting enables port_in_redirect
, it will instead add the nginx listen port(customizable via $HTTP_PORT
as per README), so if you alter that from the default 80
to say 8002
, then the docker mapping 8001:8002
will load http://localhost:8001/k8s/
fine, once JS kicks in, the url is modified to drop the trailing /
, refreshing http://localhost:8001/k8s
, then has nginx redirect to http://localhost:8002/k8s/
(note the port change).
absolute_redirect
being disabled seems to be the preferred way. As the docs say it performs a relative redirect, not absolute, this seems to not mess with the port.
from gatsby-docker.
This works better, but it still doesn't work right.
I've figured out a way to test this issue that does not involve my repo at all:
- Start up the container using the PR on port 8001 (-p 8001:80).
- Go to the link http://localhost:8001/does-not-exist/. You will get the Gatsby 404 page.
- Now go to the link http://localhost:8001/does-not-exist. You will get redirected to http://localhost/no-link/ and get the "Cannot load page" page for your browser.
This behavior is the same irrespective of what TRAILING_SLASH is set to, which likely is itself a bug (but one bug at a time...).
from gatsby-docker.
Turns out that the in the land of nginx redirects, the relative redirect is king.
It can be a little confusing to test this, since your browser remembers if you've done a 301. But using curl makes for a clearer test as to what the server is actually doing:
$ curl -v http://localhost:8001/does-not-exist > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8001 (#0)
> GET /does-not-exist HTTP/1.1
> Host: localhost:8001
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sun, 21 Jun 2020 21:45:51 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
< Location: /does-not-exist/
<
{ [162 bytes data]
100 162 100 162 0 0 8951 0 --:--:-- --:--:-- --:--:-- 9000
* Connection #0 to host localhost left intact
And for the alternative:
$ curl -v http://localhost:8001/does-not-exist/ > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8001 (#0)
> GET /does-not-exist/ HTTP/1.1
> Host: localhost:8001
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Sun, 21 Jun 2020 21:46:06 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 11103
< Connection: keep-alive
< Vary: Accept-Encoding
< ETag: "5eefd289-2b5f"
<
{ [11103 bytes data]
100 11103 100 11103 0 0 1292k 0 --:--:-- --:--:-- --:--:-- 1355k
* Connection #0 to host localhost left intact
I'm not sure what the use case is for the Docker image, but this behavior meets my needs. FWIW.
from gatsby-docker.
Related Issues (20)
- how to use onbuild? HOT 1
- Doesn't actually include Gatsby? HOT 9
- CLI / Dev image HOT 10
- doesn't work under service worker HOT 3
- About cache control HOT 1
- allow overrides in nginx configuration HOT 2
- minor typos HOT 1
- Update images in docker hub HOT 8
- Docker build fails on the first line HOT 16
- Can we update caching strategy for page-data.json HOT 1
- HTTPS? HOT 4
- ERROR [build 2/1] ADD public/ /pub HOT 3
- Feat: Cache webp images HOT 1
- Allow overrides of client_max_body_size
- Gatsby 4 support HOT 2
- Docker image outdated HOT 1
- Let's use a Map as they're a lot cheaper when arrays get large
- Blockonlinenet HOT 1
- This has no reason to exist at all.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-docker.