Welcome! Log In Create A New Profile

Advanced

Re: Possible bug in "root" declaration?

May 28, 2009 10:13AM
On Thu, May 28, 2009 at 02:51:11PM +0100, Systems Maintenance wrote:

> Below is part of a server block for a particular vhost:
>
> server {
> server_name mysite.tld ~^.+\.mysite\.tld$;
>
> set $base /var/www/mysite;
>
> if ( $host ~* "^(x|y|z)\.mysite\.tld$" ){
> set $files misc;
> }
>
> if ( $host ~* "^(admin)\.mysite\.tld$" ){
> set $files admin;
> }
>
> if ( $host = "mysite.tld" ){
> set $files home;
> }

This is not effective way. It's better to use map:

map $host $files {
default home;
mysite.tld home;
admin.mysite.tld admin;
x.mysite.tld misc;
y.mysite.tld misc;
z.mysite.tld misc;
}

> root $base/$files/www;
> error_page 404 $base/errors/404.html;
>
> location / {
> try_files $uri @webapp;
> }
>
> location @webapp {
> rewrite ^/([\w\d]+)/([\w\d]+)(.*)? /index.php/$1/$2?_params=$3 last;
> }
>
> location ~ \.php($|/) {
> set $script $uri;
> set $path_info "";
>
> if ($uri ~ "^(.+\.php)(/.+)") {
> set $script $1;
> set $path_info $2;
> }
>
> fastcgi_pass unix:/tmp/php-socket;
> include conf/fastcgi_params;
> fastcgi_intercept_errors on;
> fastcgi_param SCRIPT_FILENAME $base/$interface$script;
> fastcgi_param PATH_INFO $path_info;
> fastcgi_index index.php;
> }
>
> }
>
> What I'm seeing in my error log is that the error_page its trying to
> return is: /var/www/mysite/var/www/mysite/errors/404.html instead of the
> expected /var/www/mysite/errors/404.html

error_page uses URI, but not file:

error_page 404 /errors/404.html;

location = /error/404.html {
set /var/www/mysite;
}

> I've also tried (with no success):
>
> error_page 404 @notfound;
> location @notfound {
> root $base/errors;
> error_page 404 404.html;
> index 404.html;
> }

This is not valid way.

> Here's my version information, if it helps:
>
> # nginx -V
> nginx version: nginx/0.7.55
> built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
> configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
> --conf-path=/etc/nginx/nginx.conf
> --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid
> --with-rtsig_module --with-select_module --with-poll_module
> --with-http_ssl_module --with-http_stub_status_module
> --with-http_gzip_static_module --with-http_flv_module
> --with-http_random_index_module
> --http-log-path=/var/log/nginx/access.log
> --with-md5=/usr/lib --with-sha1=/usr/lib

--with-md5- and --with-sha1= are required to build theses libraries
from sources.

> --without-mail_pop3_module
> --without-mail_imap_module --without-mail_smtp_module

mail modules are not built by default.

> --add-module=nginx_circle_gif-0.1.3


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Possible bug in "root" declaration?

Systems Maintenance May 28, 2009 09:51AM

Re: Possible bug in "root" declaration?

Igor Sysoev May 28, 2009 10:13AM

Re: Possible bug in "root" declaration?

Systems Maintenance May 28, 2009 10:42AM

Re: Possible bug in "root" declaration?

Igor Sysoev May 28, 2009 10:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready