E
E
elfix2020-08-15 16:46:19
Nginx
elfix, 2020-08-15 16:46:19

Why doesn't giving my error page to nginx error_page work?

/home/user/web/mydomain.com/document_errors/403.html has its own error page, but returns the standard one.
Also added to #new from the example, but still the error page is not my own.
error_page 403 /403.html;
location = /403.html {
root /home/user/web/mydomain.com/document_errors;
}

Server code:

spoiler
server {

charset UTF-8;

    listen      1.1.1.1:80;
    listen [1:1:1:1::1]:80;
    server_name mydomain.com www.mydomain.com;
    error_log  /var/log/httpd/domains/mydomain.com.error.log error;

limit_conn  perip  3;
limit_conn  perserver  200;		
limit_req zone=one burst=5;




    location / {
        proxy_pass      http://1.1.1.1:8080;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
            root           /home/user/web/mydomain.com/public_html;
            access_log     /var/log/httpd/domains/mydomain.com.log combined;
            access_log     /var/log/httpd/domains/mydomain.com.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

#old дефолтный из vesta тоже не работает
#    location /error/ {
#        alias   /home/user/web/mydomain.com/document_errors/;
#   }

#new взял из интернета пример
error_page 403 /403.html;
location = /403.html {
root /home/user/web/mydomain.com/document_errors;
}


    location @fallback {
        proxy_pass      http://1.1.1.1:8080;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

proxy_cache user;
proxy_cache_valid any 3m;
proxy_cache_valid 404 502 1m;
proxy_cache_valid 503      0;
proxy_cache_valid 403      0;
proxy_cache_bypass $nocache;
proxy_no_cache $nocache;

#test тест отдачи ошибки
if ($http_user_agent = "Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.18"){
    return 403;
}



}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question