Welcome! Log In Create A New Profile

Advanced

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly
October 06, 2019 07:16AM
On Sat, Oct 05, 2019 at 12:44:30PM -0400, Alex Med wrote:

Hi there,

Good that you have a configuration that works for you.

If you want to spend more time on it, you may be able to remove some of
the duplication; but that is not necessary.

> I even included the proxy configuration parameters for the
> websocket connection to work.

Good stuff.

I would expect that the extra "websockets" configuration is not necessary
for non-websocket requests; so you might be able to add new location{}s
for just-websocket-requests -- but again, if what you have works, there
is no need to change anything.

> I noticed that the location =/ does not
> support OR so I had create two additional locations to catch paths without
> the end forward slash.

Correct. "location =" is for an exact string match.

> Is there a limit in the number of location that a
> configuration file should have?

"As many as it needs". If it needs more than your hardware can handle,
you need different hardware.

Which is just a way of saying: no, there is no practical limit that you
will meet.

> Thank YOU again for being in this forum and helping everyone!

You're welcome.

> location ~
> ^/(api|contentAsset|categoriesServlet|DotAjaxDirector|html|dwr|dA|JsonTags)/
> {

So - this location will match requests that start with "/X/" for each of
the eight strings in the pattern -- matching case-sensitively, because
you write "~" and not "~*".

> proxy_pass http://xxx.xx.xx.xxx:IIII;

That line says to proxy_pass these requests elsewhere.

> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_connect_timeout 600;
> proxy_send_timeout 600;
> proxy_read_timeout 600;
> proxy_redirect off;

And those lines set some proxy-specific variables.

Because those same extra lines appear in many location{}s, you *could*
choose to put them at server{} level once, outside all location{}s, and
they would inherit into those location{}s, per the normal nginx method.

> location = /categoriesServlet {

This location will match exactly that request.

> proxy_pass http://xxx.xx.xx.xxx:IIII;

That line is needed.

> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_connect_timeout 600;
> proxy_send_timeout 600;
> proxy_read_timeout 600;
> proxy_redirect off;
>
> ###
> ### ADD THIS FOR WEBSOCKET SUPPORT
> ###
>
> proxy_http_version 1.1;
> proxy_set_header Upgrade $http_upgrade;
> proxy_set_header Connection "Upgrade";

Those lines could be removed from here, if they were all set at server{}
level.

> location = /JSONTags {
> proxy_pass http://xxx.xx.xx.xxx:IIII;

Same story here -- exactly one request handled, this capitalisation only.

> location ~ [A-Z] {

This will match any request that includes a capital letter.

> return 301 $scheme://$host$my_uri_to_lowercase;

And will return a redirect to the matching lowercased-request.

> proxy_pass http://xxx.xx.xx.xxx:IIII;

This line (and the rest of them below) will not do anything, because the
"return" happens first.

> location / {
> proxy_pass http://xxx.xx.xx.xxx:IIII;

This location will match any other requests, and will proxy_pass them
to upstream.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 03, 2019 11:36AM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly October 03, 2019 11:56AM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 03, 2019 12:21PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 03, 2019 01:03PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly October 03, 2019 01:38PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly October 03, 2019 03:06PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 04, 2019 03:36PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly October 04, 2019 04:52PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 05, 2019 12:41PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Alex Med October 05, 2019 12:50PM

Re: Nginx Reverse Proxy Lowercase URL and some exceptions to the URL

Francis Daly October 06, 2019 07:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 242
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready