N
N
nepster-web2014-02-17 21:31:55
Nginx
nepster-web, 2014-02-17 21:31:55

Why in Ngnix does the request not go to location?

There are 3 urls:
site.ru/itest/
site.ru/qtest/
site.ru/ztest/
The task is this:
site.ru/itest/ - should be proxied to 192.168.1.121
site.ru/qtest/ - should be proxied to 192.168. 1.122 site.ru/ztest/
- should be proxied to 192.168.1.123
To start the test:

server {
        listen          80;
        server_name   localhost; 

        location / {
                proxy_pass http://192.168.1.121;
        }          
}

When you enter site.ru, everything correctly gets where you need to
. I try to do it like this:
server {
        listen          80;
        server_name   localhost; 

        location /itest {
                proxy_pass http://192.168.1.121;
        }   
       
        location /qtest {
                proxy_pass http://192.168.1.122;
        }     
     
        location /ztest {
                proxy_pass http://192.168.1.123;
        }          
}

And I get a 404 error. Please tell me what is the problem?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
N
nepster-web, 2014-02-18
@nepster-web

Solution:
In the /game/public folder, it was necessary to create a deberc folder

A
Andrew, 2014-02-18
@kaasius

As they like to say in the nginx mailing list - show the whole config. What is written should work.

Q
quex, 2014-02-17
@quex

try adding trailing slashes

location /itest/ { ... }
...

N
nepster-web, 2014-02-18
@nepster-web

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
  worker_connections 768;
  # multi_accept on;
}

http {

  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  # server_tokens off;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";

  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # nginx-naxsi config
  ##
  # Uncomment it if you installed nginx-naxsi
  ##

  #include /etc/nginx/naxsi_core.rules;

  ##
  # nginx-passenger config
  ##
  # Uncomment it if you installed nginx-passenger
  ##
  
  #passenger_root /usr;
  #passenger_ruby /usr/bin/ruby;

  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  #include /etc/nginx/sites-enabled/*;
}

In /etc/nginx/conf.d/*.conf 1 file with the content:
server {
        listen          80;
        server_name   localhost; 

        location /itest {
                proxy_pass http://192.168.1.121;
        }   
       
        location /qtest {
                proxy_pass http://192.168.1.122;
        }     
     
        location /ztest {
                proxy_pass http://192.168.1.123;
        }          
}

N
nepster-web, 2014-02-18
@nepster-web

nginx config on virtual server doesn't get into location /deberc

server {
    listen       80;
    server_name 192.168.1.121;

    charset utf8;
    error_log /game/nginx/log/error.log;
    access_log  /game/nginx/log/access.log  main;

    #root /game/public;


    location /deberc {
        root /game/public;
        index index.html index.htm;
    }

    location / {
        root /game/public;
        index index.html index.htm;
    }

    error_page  404              /404.html;


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /game/public;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question