Questions related to nginx location directive should use this tag.
Questions tagged [nginx-location]
1424 questions
2
votes
0 answers
Why is Nginx proxy_pass ignoring add_headers when used with variables?
I am trying to make a dynamic CORS proxy using Nginx, so I can use multiple API's from my front-end code without any CORS errors. My current way is using multiple location blocks, one for each domain, which works, but I would rather have a dynamic…

Charley Wright
- 73
- 5
2
votes
0 answers
How do I configure nginx to serve files with a prefix?
I am trying to host static files in kubernetes with an nginx container, and expose them on a private network with istio.
I want the root of my server to exist at site.com/foo, as I have other applications existing at site.com/bar, site.com/boo,…

DCoolaid
- 21
- 2
2
votes
1 answer
Add a custom header while redirecting in NGINX
I am trying to redirect all API calls to an authorization service endpoint using nginx. I will need to pass a custom header in which i intend to pass the original uri or $request_uri.
Trying the below:
location /api/other {`
add_header…

Angshuman
- 697
- 8
- 29
2
votes
0 answers
Angular router takes over nginx location
I have an angular app thet is served by node.
I've configured nginx to serve node on the root route "/".
Then I configured a secend location for another api on the route "/api".
Now when I open the browser for the first time and I try to get "/api"…

אברימי פרידמן
- 418
- 5
- 13
2
votes
1 answer
Nginx location & sub location blocks
I'm not very experienced with nginx but I know enough to get by.
Recently I came across a bug that is now resolved, but I wanted clarification as to why this would be occuring.
So I have several node applications and nginx works as a reverse proxy…

user1157885
- 1,999
- 3
- 23
- 38
2
votes
0 answers
Logging POST body (request and response) with ingress-nginx
It seems that out of the box ngx_http_core_module should log request_body if it's part of the log_format.
However, Im not seeing this working for anything that includes auth_request in location block. Im not entirely sure what causes it. It appears…

nixgadget
- 6,983
- 16
- 70
- 103
2
votes
0 answers
Force chunk transfer enconding in NGINX for proxied responses
I've got an upstream that sends back responses in "applicaion/json" format. NGINX is used as a reverse proxy in my project. However, I have a hard requirement that client applications only accept the chunked encoding response. And hence somehow I…

minex
- 329
- 1
- 5
2
votes
2 answers
Setup phpMyAdmin inside website subdirectory
I have an NGINX web server with two domains and it also runs phpMyAdmin.
phpMyAdmin is working fine and I access it through the below non-https url:
public-ip-address/phpMyAdmin
This is how the symbolic link was setup:
sudo ln -s…

Shoumik Das
- 441
- 5
- 16
2
votes
1 answer
How to config Nginx serves desktop version and mobile version from two different folders
I have only one subdomain name available, e.g. https://sport.abc.com,
I would like to serve desktop version from a folder called /wwwroot/sport.abc.com/dist/sport/desktop/ , however when detecting it's a mobile client, serve from a different folder…

jfordec H
- 85
- 1
- 1
- 6
2
votes
1 answer
How to configure nginx to use same port with same server name for 2 sites
I have 2 sites in one debian machine. Currently one is running on port 443/80 and another one is running on port 8090. My requirement is to run both sites on 443 and if I enter site.com/1 - I should be redirected to site 1 and if I enter site.com/2…

karikevinod
- 633
- 7
- 16
2
votes
0 answers
Direct URL access results in 404 page not found on Nginx Server
I have deployed my node.js application on nginx server and it is up and running. I am able to access the application using the domain name that i bought. For example [www.myshopping.com] this is dummy name.
When i am navigating to other URL through…

rak_6040
- 65
- 1
- 1
- 6
2
votes
0 answers
NGINX always returns {"status":400,"message":"Bad request"} - not able to consume upstream api
Below is my config:
am always getting bad request error when trying to consume api response. But it looks like the upstream api not getting recognized in the configs . please help.
api_gateway.conf
log_format api_main '$remote_addr - $remote_user…

Satscreate
- 495
- 12
- 38
2
votes
1 answer
Regex in nginx location match extension without "resolve"
I am not a god in Regular Expressions and stuck with a complex location regex.
I have a location block in my nginx config to make sure images and other media are cached. But if "resolve" is in the URL it should not match and skip the block. I can't…

Kees Schepers
- 2,248
- 1
- 20
- 31
2
votes
1 answer
Setting same domain name in a variable not working for multiple location block in nginx
I want to resolve DNS every time when a new request will come,
I am trying to resolve DNS dynamically in Nginx by setting DNS in a variable. It is working correctly for the below example.
server {
location /mypath {
resolver 10.0.3.2…

Darshan Jain
- 316
- 2
- 9
2
votes
1 answer
Nginx remove substring and add as url param
This is related to this question, but the answer did not work for me.
I need to turn this: /api/batch.json?param=1
into /batch?param=1&format=json
Nginx location:
location /api/batch {
proxy_set_header X-Real-IP $remote_addr;
…

Werner Raath
- 1,322
- 3
- 16
- 34