Hello,
We provide a subdomain for each user, for example:
paul.ourdomain.com
jay.ourdomain.com
bob.ourdomain.com
xxxxx.ourdomain.com
Currently, I am doing this manually by adding another config in
/etc/nginx/conf.d for each subdomain. A typical conf looks like:
server {
listen 80;
server_name paul.ourdomain.com ;
root /srv/www/users/paul/wp;
index index.php;
access_log /var/log/nginx/vhosts/paul.access.log;
error_log /var/log/nginx/vhosts/paul.error.log;
include /etc/nginx/excludes.conf;
include /etc/nginx/wordpress.conf;
include /etc/nginx/expires.conf;
}
Is there I way I can abstract this, and prevent creating a configuration
for each subdomain? I was reading something about map, but don’t fully
understand it.
Thanks.
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 20, 2012, 8:40pm
2
On Tue, Feb 21, 2012 at 2:28 AM, justin [email protected] wrote:
/etc/nginx/conf.d for each subdomain. A typical conf looks like:
access_log /var/log/nginx/vhosts/paul.access.log;
Probably something like this:
map $host $username {
some.domain.com usera;
another.one.net userb;
}
server {
root /srv/www/users/$username/wp;
access_log /var/log/nginx/vhosts/$username.access.log;
…
}
Or this (without map):
server {
server_name ~^(?.+).domain.com$;
root /srv/www/users/$username/wp;
…
}
–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
justin
February 20, 2012, 8:56pm
3
Edho,
Thank you very much for the assistance. Here is what I used, and seems
to be working perfectly:
server {
listen 80;
server_name ~^(?.+).mydomain.com$;
root /srv/www/users/$user/wp;
index index.php;
access_log /var/log/nginx/vhosts/$user.access.log;
error_log /var/log/nginx/vhosts/$user.error.log;
include /etc/nginx/excludes.conf;
include /etc/nginx/wordpress.conf;
include /etc/nginx/expires.conf;
}
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 20, 2012, 10:15pm
4
Hello!
On Mon, Feb 20, 2012 at 02:55:39PM -0500, justin wrote:
Edho,
Thank you very much for the assistance. Here is what I used, and seems
to be working perfectly:
[…]
access_log /var/log/nginx/vhosts/$user.access.log;
error_log /var/log/nginx/vhosts/$user.error.log;
Note: the “error_log” directive doesn’t support variables, and
this will log all errors into “$user.error.log” file.
Maxim D.
justin
February 21, 2012, 1:19am
5
Actually, I think I found how to set the 404:
location ~ .php$ {
if (!-f $document_root/$fastcgi_script_name) {
log_not_found off;
return 404;
}
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_pass php1.local.pagelines.com:9000 ;
}
But I can’t use log_not_found off, getting an error about the ability to
use this in the location. Basically, I don’t want an error logged if
somebody types:
foobar.mydomain.com
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 21, 2012, 2:11am
6
On Tue, Feb 21, 2012 at 7:18 AM, justin [email protected] wrote:
fastcgi_intercept_errors off;
fastcgi_pass php1.local.pagelines.com:9000 ;
}
But I can’t use log_not_found off, getting an error about the ability to
use this in the location. Basically, I don’t want an error logged if
somebody types:
Try
try_files $uri =404;
–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
justin
February 21, 2012, 12:45am
7
How do I handle the fallback, i.e. somebody types:
foobar.mydomain.com
Which does not exists, right now I am getting: no input file. Instead,
would love to simply return a 404 error, or even better serve a custom
static 404 error page.
Maxim:
Bummer that error_log does not support variables, anyway to do this
dynamically?
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 21, 2012, 2:33am
8
On Tue, Feb 21, 2012 at 8:28 AM, justin [email protected] wrote:
This is for Wordpress, I already have a try_files. I want to log not
found everywhere else, just not in the dynamic subdomain
You can (should) have another try_files in location ~ .php$
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
try_files $uri =404;
nginx mailing list
[email protected]
nginx Info Page
–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
justin
February 21, 2012, 2:40am
9
Edho,
Still seeing logged:
2012/02/20 17:37:18 [error] 12840#0: *27 testing “/srv/www/users/boo/wp”
existence failed (2: No such file or directory) while logging request
With:
location ~ .php$ {
try_files $uri =404;
}
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 21, 2012, 2:28am
10
This is for Wordpress, I already have a try_files. I want to log not
found everywhere else, just not in the dynamic subdomain
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
if (!-f $document_root/$fastcgi_script_name) {
log_not_found off;
return 404;
}
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_pass php1.local.pagelines.com:9000 ;
}
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 21, 2012, 7:46pm
11
Still trying to track down what is causing the following to be logged in
the error log:
2012/02/21 10:42:13 [error] 13884#0: *19 testing
“/srv/www/users/foobar/wp” existence failed (2: No such file or
directory) while logging request, client: X.X.X.X, server:
~^(?.+).mydomain.com$, request: “GET / HTTP/1.1”, host:
“foobar.pagelines.com ”
I believe the problem is since I am configuring the server_name and root
dynamically:
server_name ~^(?.+).mydomain.com$;
root /srv/www/users/$user/wp;
And obviously the root directory does not exist for foobar. Is there a
way to suppress these errors, or maybe check if the root directory
exists?
Posted at Nginx Forum:
Hello, We provide a subdomain for each user, for example: paul.ourdomain.com jay.ourdomain.com bob.ourdomain.com xxxxx.ourdomain.com Currently, I am doing this manually by adding another config in /etc/nginx/conf.
justin
February 21, 2012, 2:53am
12
On Tue, Feb 21, 2012 at 8:40 AM, justin [email protected] wrote:
Edho,
Still seeing logged:
2012/02/20 17:37:18 [error] 12840#0: *27 testing “/srv/www/users/boo/wp”
existence failed (2: No such file or directory) while logging request
The errors seems like coming from root directive. I don’t know how to
prevent logging that, sorry. Anyway, the try_files in location php
block should allow you to use custom static 404 error page.
–
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org