Questions related to nginx location directive should use this tag.
Questions tagged [nginx-location]
1424 questions
7
votes
2 answers
Using nginx map directive to dynamically set proxy upstream
I'm trying to make my Nginx a bit more dry, as it's acting as a reverse proxy for nearly 20 servers. Here's what I'm trying to do, all the hostnames and stuff are changed/examples:
map $http_host $backend {
baz.mydomain.com …

Tal Bull
- 389
- 1
- 2
- 10
7
votes
1 answer
Load CSS and Js files with Nginx
I am trying to serve an Angular deployed site (I have a dist directory with the index.html file) in Nginx. In that directory I have:
index.html
js files
css files
assets
I don't have experience in Nginx, so I am trying to serve correctly this…

Sredny M Casanova
- 4,735
- 21
- 70
- 115
7
votes
1 answer
Nginx error 404 when using autoindex
I'm completely new to nginx. I've installed nginx on windows pc.
What I want to do is server a list of files in D:\ on localhost:8082/list.
If I use the following conf:
server {
listen 8082;
location / {
root D:/;
…

imlokesh
- 2,506
- 2
- 22
- 26
7
votes
1 answer
Nginx multiple locations with different roots
I have really simple nginx configuration with 3 locations inside. Each of them have it's own root directory + I should be able to add another in the future easily.
What I want:
Request /admin => location ^/admin(/|$)
Request /admin/ => location…

David Kudera
- 806
- 2
- 8
- 14
7
votes
0 answers
Dynamic resolver in nginx
I have an nginx config that varies from prod to dev. I'm currently using map to tease out the differences based on $host and $server_name, but the one thing I can't seem to make variable is the resolver. As it stands, I have to set ${RESOLVER} and…

timsabat
- 2,208
- 3
- 25
- 34
7
votes
1 answer
Nginx "location ~ ." vs "location ~* \."
Is there a difference between the 3 following directives?
location ~* \.(png)$ {
expires max;
log_not_found off;
}
location ~ \.(png)$ {
expires max;
log_not_found off;
}
location ~ .(png)$ {
expires max;
log_not_found off;
}
Thank…

The Dude man
- 383
- 6
- 19
7
votes
4 answers
Nginx fails to create directories on Windows 10 with error: nginx: CreateFile()...failed
I need to find a way/setting to allow Nginx to run a .bat file that will create directories and files via a WINDOWS service; my OS is Windows 10.
Currently, our windows service fails to create directories and files with the following:…

pelican
- 5,846
- 9
- 43
- 67
7
votes
4 answers
Nginx config for Yii 2 Advanced App Template
I would like to configure the Nginx web-server in such a way that:
Requests to the /index.php URI should be handled by public_html/frontend/web/index.php
Requests to the /admin/index.php URI should be handled by…

serghei
- 3,069
- 2
- 30
- 48
6
votes
2 answers
How to configure nginx's default.conf
I'm trying to configure default.conf in /etc/nginx/conf.d to show a simple landing page located at /home/ubuntu/project-source/company/entry/index.html.
The domains are set up correctly as far as I know to point to the server
A: test24.company.io…

Edito
- 3,030
- 13
- 35
- 67
6
votes
1 answer
nginx ssl_trusted_certificate directive not working
When I try to start the nginx server with this configuration I get an error
nginx: [emerg] no ssl_client_certificate for ssl_client_verify
My Configuration looks like
# HTTPS server
server {
listen 4443;
server_name localhost;
…

user1918858
- 1,202
- 1
- 20
- 29
6
votes
1 answer
Nginx try_files not working for default index.html
I am using $geoip_country_code module of nginx to redirect user based on IP. My config code is as given below-
server {
listen 80;
gzip on;
server_name example.com;
root html/example;
location / {
index…

async_soul
- 143
- 1
- 8
6
votes
3 answers
How to configure redirects to url with trailing slash in nginx?
I want to redirect URLs without slash to the path with trailing slash.
So /some-url to /some-url/
And the rest of the URLs, like
/some-url.xml
/some-url?
/some-url?q=v
/some-url/
Should stay without redirection.
I found this article…

Pawel
- 466
- 1
- 7
- 20
6
votes
1 answer
Nginx case insensitive proxy_pass
I've got a site called http://example.com, with an app running that can be accessed at http://example.com/app1. The app1 is sitting behind an nginx reverse proxy, like so:
location /app1/ {
proxy_pass http://localhost:8080/;
…

JonLuca
- 850
- 6
- 25
6
votes
2 answers
Nginx dynamic location path configuration
Firstly I want to state that I'm rather new to nginx, I basically only know what I've learned over the last week.
That said, I currently have a Nginx server with a standard configuration of:
server {
listen 80;
server_name site.com;
root…

mformigo
- 65
- 2
- 2
- 7
6
votes
1 answer
nginx set invalid number of arguments in "set" directive
I'm using the set directive as described in the nginx doc but I keep getting this error:
nginx_1 | 2016/09/13 15:06:08 [emerg] 8#8: invalid number of arguments in "set" directive in /etc/nginx/conf.d/default.conf:9
nginx_1 | nginx: [emerg]…

Slakk
- 107
- 1
- 1
- 6