0

/etc/nginx/sites-available/default-proxy:


server {
    listen xxx.xx.xxx.xxx:80 default_server;
    proxy_read_timeout 200s;
    access_log /var/log/nginx/default-access.log;
    error_log /var/log/nginx/default-error.log;

    include static.conf;

    location / {
        root              /var/www/web/sites;
        try_files         /$host/ @default_host;
        proxy_pass        http://127.0.0.1:80;
        proxy_redirect    http://127.0.0.1:80/ /;
    }

    location @default_host {
        proxy_pass        http://127.0.0.2:80;
        proxy_redirect    http://127.0.0.2:80/ /;
    }

    location @mass_hosting {
        root              /var/www/web/sites;
        try_files         /$host/ @default_host;
        proxy_pass        http://127.0.0.1:80;
        proxy_redirect    http://127.0.0.1:80/ /;
    }
}

server {
    listen xxx.xx.xxx.xxx:443 ssl;
    server_name domain.ru;

    proxy_read_timeout 200s;
    access_log /var/log/nginx/default-access.log;
    error_log /var/log/nginx/default-error.log;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate     /var/www/web/ssl/domain.ru.crt;
    ssl_certificate_key /var/www/web/ssl/domain.ru.key;

    location / {
        root              /var/www/web/sites;
        try_files         /$host/ @default_host;
        proxy_pass        https://127.0.0.1:443;
        proxy_redirect    https://127.0.0.1:443/ /;
    }

    location @default_host {
        proxy_pass        http://127.0.0.2:443;
        proxy_redirect    http://127.0.0.2:443/ /;
    }

    location @mass_hosting {
        root              /var/www/web/sites;
        try_files         /$host/ @default_host;
        proxy_pass        http://127.0.0.1:443;
        proxy_redirect    http://127.0.0.1:443/ /;
    }
}

in the access-default.log file, the entries are normal, but the default-error.log file is empty.Why? p.s what is the easiest way to check if the problem is fixed? call 404 error and check the log again?

  • Just hit a request page which is not available, 404 error mean page not found. – asktyagi Jun 2 at 12:17
  • ok, the problem still as relevant - error-default.log is empty – Егор Трегубенко Jun 2 at 16:21
0
  • make sure to check your access.log for these missing 404 (this may happen due to error_page or try_files directives)
  • make sure "log_not_found" is not set to "off"[1]
  • make sure the upstreams you are using are not returning a response indicating a 404 while returning a 200 status code (this would then be logged as a 200 in the access-log)

[1] https://nginx.org/en/docs/http/ngx_http_core_module.html#log_not_found

  • access_log is ok -404 : xx.xxx.xx.xxx - - [03/Jun/2019:00:12:46 -0400] "GET /s111111111 HTTP/1.1" 404 3759 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/xx.0.3729.169 Safari/537.36" I have an additional question : how do I know what to be in @mass_hosting and @default_host ? – Егор Трегубенко Jun 3 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.