Welcome! Log In Create A New Profile

Advanced

Re: Allow internal redirect to URI x, but deny external request for x?

All files from this thread

File Name File Size   Posted by Date  
smime.p7s 3.5 KB open | download j94305 09/03/2019 Read message
smime.p7s 3.5 KB open | download j94305 09/04/2019 Read message
September 04, 2019 11:44AM
Hi Lewis,

  no, that won't cause double requests.

/myapp/current/blah.html

307 => /myapp/releases/1.2.0/blah.html

and from thereon (as we did not redirect internally, but rather
externally), any further accesses will happen unter the true "releases"
path (ideally, as relative URLs).

That's only one redirection overhead in the beginning.

The redirection will forward any path under "current", i.e.,

/myapp/current/index.html => /myapp/releases/1.2.0/index.html

/myapp/current/images/icon.jpg => /myapp/releases/1.2.0/images/icon.jpg

and so on. Only the first request will be a redirection. All subsequent
requests would use the true path.

We use this approach with a number of applications, e.g., multiple
Jenkins or Gitlab installations behind one NGINX, but also with
front-end components being deployed with a CI/CD pipeline in Amazon S3,
that also switches the "current" link to the then respectively latest
version of the artifact. The good thing is: if a user has loaded version
1.2.0, all links into the releases/1.2.0 path will continue to work,
even if you upload a new version 1.2.1 and make that the "current"
version. Any URLs with the "current" part in it will not be used as a
reference except in the initial process of accessing the latest version
of an app. From there, everything will always and only use the canonical
form in the "private" releases path. That's the nature of a redirection.

This is the effect you get by having the HTTP equivalent of a symbolic
link in the NGINX (visible to the browser), not in the file system
(which is opaque to users). The file system link will (over time) serve
different contents under the same URL, so in fact, addressing changes
with every deployment. The suggested approach keeps URL addressing
constant and just changes the entry pointer on a new deployment.

I agree that this is not the solution that first comes to ones mind, but
it does solve a number of nasty versioning issues we have run into over
time. Your mileage may vary :-)

Good luck!

--Jürgen



On 04.09.2019 17:28, J. Lewis Muir wrote:
> Wouldn't the 307 redirection mean that for*every* request, nginx has to
> issue a 307 and then the client has to request the versioned URI which
> nginx then has to server; so a double-request for every resource?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Attachments:
open | download - smime.p7s (3.5 KB)
Subject Author Posted

Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 30, 2019 01:34PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 30, 2019 02:22PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 30, 2019 02:38PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 30, 2019 03:00PM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly August 30, 2019 04:56PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 30, 2019 06:00PM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly August 30, 2019 07:22PM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly August 31, 2019 03:28AM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 31, 2019 11:06AM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 31, 2019 10:12AM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly August 31, 2019 04:52PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 31, 2019 05:56PM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly September 02, 2019 05:04PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir September 03, 2019 01:28PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir September 03, 2019 05:32PM

Re: Allow internal redirect to URI x, but deny external request for x?

Ian Hobson August 30, 2019 03:02PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir August 31, 2019 11:32AM

Re: Allow internal redirect to URI x, but deny external request for x?

Francis Daly August 30, 2019 04:34PM

Re: Allow internal redirect to URI x, but deny external request for x?

gariac August 30, 2019 05:24PM

Re: Allow internal redirect to URI x, but deny external request for x?

Ian Hobson August 31, 2019 10:42AM

Re: Allow internal redirect to URI x, but deny external request for x?

j94305 August 30, 2019 06:28PM

Re: Allow internal redirect to URI x, but deny external request for x?

gariac August 31, 2019 03:20PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir September 03, 2019 11:30PM

Re: Allow internal redirect to URI x, but deny external request for x? Attachments

j94305 September 03, 2019 11:56PM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir September 04, 2019 11:30AM

Re: Allow internal redirect to URI x, but deny external request for x? Attachments

j94305 September 04, 2019 11:44AM

Re: Allow internal redirect to URI x, but deny external request for x?

J. Lewis Muir September 04, 2019 12:32PM

Re: Allow internal redirect to URI x, but deny external request for x?

j94305 September 10, 2019 02:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 95
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready