Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#232 closed defect (invalid)

[bug] Location Alias doesn't work 1.3.7

Reported by: Alex Storn Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a: FreeBSD 9.1-PRERELEASE amd64
nginx -V: nginx version: nginx/1.3.7
TLS SNI support enabled
configure arguments: --add-module=/root/nginx_modules/nginx-limit-traff --add-module=/root/nginx_modules/mod_strip --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx-error.log --user=www --group=www --with-file-aio --with-ipv6 --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --add-module=/usr/ports/www/nginx-devel/work/agentzh-headers-more-nginx-module-6586984 --with-http_stub_status_module --add-module=/usr/ports/www/nginx-devel/work/naxsi-0.46-1/naxsi_src --with-pcre --with-http_ssl_module

Description

Not working alias on nginx/1.3.7

error_page 403 = /err/403.html;
error_page 404 = /err/404.html;

location /err/ {
   alias /home/site/www/errors;
}

# ls /home/site/www/errors

403.html
404.html

Return

404 Not Found

nginx

Change History (6)

comment:1 by Alex Storn, 12 years ago

location ~ "^/err/([0-9]{3})\.html$" {
   internal;
   alias /home/site/www/errors;
}

hm reddirect to /err/404.html/

На этой странице обнаружена циклическая переадресация

Last edited 12 years ago by Alex Storn (previous) (diff)

comment:2 by Valentin V. Bartenev, 12 years ago

According to your configuration nginx will try to open /home/site/www/errors403.html or /home/site/www/errors404.html in case of 403 or 404 errors, respectively.

Do you actually have these files in your /home/site/www directory?

comment:3 by Alex Storn, 12 years ago

Replying to Valentin V. Bartenev:

According to your configuration nginx will try to open /home/site/www/errors403.html or /home/site/www/errors404.html in case of 403 or 404 errors, respectively.

Do you actually have these files in your /home/site/www directory?

<domain> = /home/site/www/forum
(CDN) static.<domain> = /home/site/www/static
errors page for all domain/subdomain's = /home/site/www/errors

Last edited 12 years ago by Alex Storn (previous) (diff)

comment:4 by Valentin V. Bartenev, 12 years ago

Ok. Let me explain, so you do not have errors403.html and errors404.html in the /home/site/www directory? Or please note, that you don't have ending slash in your alias directive while you have it in the location block.

/home/site/www/errors403.html is not the same file as /home/site/www/errors/403.html.

in reply to:  1 comment:5 by Maxim Dounin, 12 years ago

Resolution: invalid
Status: newclosed

Obviously enough the problem is lack of understanding how alias works.

  • The config provided in a ticket description doesn't work due to missing "/" in the "alias" directive, as already outlined in Valentin's answers. Correct one would be as follows:
    error_page 403 = /err/403.html;
    error_page 404 = /err/404.html;
    
    location /err/ {
       alias /home/site/www/errors/;
    }
    
    Note the "/" after "errors".
  • The config provided in the first comment (with a location given by a regular expression) doesn't work as in a regexp location "alias" defines full path to a file.

See here for documentation: http://nginx.org/r/alias.

comment:6 by Alex Storn, 12 years ago

thanks

Note: See TracTickets for help on using tickets.