2

Previously (about 5months ago) everything was working well, right now, instead of @app index.html is served.

Same problem on nginx version: 1.6.2 and 1.8

This is my /etc/nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    server {
        listen       80;
        server_name  localhost;
        root   /opt/app/server/html;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /var/www/html;
        }
    }
    include /etc/nginx/conf.d/*.conf;
}

This is my /etc/nginx/conf.d/user_example.conf

server {
    listen 80;
    server_name user.example.com;
    root /home/user/webapps/;

    location / {
        try_files $uri $uri/ @app; (removed index.html;)
    }

    location @app {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_pass http://127.0.0.1:9000;
    }
}

Could someone explain me why @app is skipped?

Hm this could be another question, but ... If i remove /home/user/webapps/index.html and go to user.example.com I get 403 Forbidden. And i want to 'execute' proxy_pass from @app, what i need to change?

Changed config - but still would like to know how to use that named location.

server {
    listen 80;
    server_name user.example.com;
    root /home/user/webapps/;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_pass http://127.0.0.1:9000;
    }
}

Problem was not the named location @app but $uri/ wrong permissions over directory /home/user/webapps. Problem solved.

Abc Xyz
  • 608
  • 1
  • 8
  • 16
  • Invalid syntax - see [this](http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files). Only the last element can be a named location, an error code or a default URI - choose one only. – Richard Smith Mar 05 '16 at 19:17
  • Removed index.html but on the site user.example.com i still see that result from index.html - weird. I will share more results later ... testing right now. – Abc Xyz Mar 05 '16 at 19:53
  • 1
    If there is an `index.html` file present, the default `index` rule will serve it up. See [this](http://nginx.org/en/docs/http/ngx_http_index_module.html#index). – Richard Smith Mar 05 '16 at 19:55
  • Richard thank you for your time, lerned new things about Nginx. +1 – Abc Xyz Mar 05 '16 at 21:31

0 Answers0