# Configuration problem

**URL:** <https://www.ruby-forum.com/t/configuration-problem/220113>\
**Category:** NGINX\
**Created:** [May 29, 2012, 12:22pm UTC](https://www.ruby-forum.com/t/configuration-problem/220113 "2012-05-29T12:22:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [May 29, 2012, 12:22pm UTC](https://www.ruby-forum.com/t/configuration-problem/220113/1 "2012-05-29T12:22:53Z")

</div>

Hi All,

I wish to configure phplist under nginx on multiple domains.

phplist is installed into /lists in the root directory, and  
/lists/config/config.php is amended to give access to a php database.

I though to move /lists to a location outside the normal web tree,  
replace /config/config.php with a script to test the domain name in  
$\_SERVER, and load the appropriate configuration parameters.

So the first job is to move /lists for one domain and get that working.  
The nginx configuration I have tried is this.

# Statements for [example.com](http://example.com) virtual server

server {  
listen 80;  
server\_name [example.com](http://example.com) [www.example.com](http://www.example.com);  
root /var/www/example.com/htdocs;  
access\_log /var/www/example.com/access.log;  
index index.php index.html index.htm;  
location = /favicon.ico {  
log\_not\_found off;  
access\_log off;  
}  
location = /robots.txt {  
allow all;  
log\_not\_found off;  
access\_log off;  
}  
location ^~ /usage {  
auth\_basic “Hello, please login”;  
auth\_basic\_user\_file /var/www/example.com/passwords;  
}  
location ^~ /lists {  
root /var/www/phplist;  
}  
location ~ .php$ {  
include /etc/nginx/fastcgi\_params;  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_param SCRIPT\_FILENAME  
$document\_root$fastcgi\_script\_name;  
}  
try\_files $uri $uri/ /index.php;  
}

The idea being that the " location ^~ /lists {" stanza moves the root,  
and the “location ~ .php$ {” stanza sends .php files off to fast\_cgi,  
while nginx serves other assets from the relevant one of the two roots.

Unfortunately, nginx serves the phplist php files, without passing them  
to fast\_cgi, and the browser treats them as downloads. ☹

What is wrong with my configuration?

Thanks

Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [May 29, 2012, 12:27pm UTC](https://www.ruby-forum.com/t/configuration-problem/220113/2 "2012-05-29T12:27:51Z")

</div>

29.05.2012, 17:22, “Ian H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> location = /favicon.ico {  
> auth\_basic\_user\_file /var/www/example.com/passwords;  
> }  
> location ^~ /lists {  
> root /var/www/phplist;  
> }  
> location ~ .php$ {  
> include /etc/nginx/fastcgi\_params;  
> fastcgi\_pass 127.0.0.1:9000;  
> fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
> }

- location ~ ^/lists/.+.php$ {
- root /var/www/phplist;
- include /etc/nginx/fastcgi\_params;
- fastcgi\_pass 127.0.0.1:9000;
- fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;
- }

> What is wrong with my configuration?
> 
> Thanks
> 
> Ian

–  
br, Denis F. Latypoff.

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [May 29, 2012, 2:32pm UTC](https://www.ruby-forum.com/t/configuration-problem/220113/3 "2012-05-29T14:32:19Z")

</div>

On Tue, May 29, 2012 at 11:22:06AM +0100, Ian H. wrote:

> ```
> location = /favicon.ico {
> auth_basic_user_file /var/www/example.com/passwords;
> 
> ```
> 
> }  
> Thanks
> 
> Ian

Quoting [Module ngx\_http\_core\_module](http://nginx.org/r/location), “If the most specific prefix  
location has the “^~” prefix then regular expressions are not checked.”

In your case, if the request matches the prefix location “/lists”,  
you explicitly told nginx not to match it against regexp locations  
including “.php$”. “location /lists” would be a proper spelling.

Please also see

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

for a working example.
