Welcome! Log In Create A New Profile

Advanced

Repeating fastcgi directives seven times

Posted by remacle 
Repeating fastcgi directives seven times
December 15, 2011 06:35PM
Hi Forum... I am going through a learning curve with the amazing Nginx and looking for advice...

I have several protected directories (folders), some are subdomains and all require to parse php within .html files...

The below is my /etc/nginx/sites-available/mydomain.com and works properly... My question is:

"Is there a more efficient way to write the below directives", I am repeating fastcgi directives seven times and feel there's got to be a leaner, more global approach.

All tips greatly appreciated

server {
listen 80;
server_name www.mydomain.com;
rewrite ^/(.*) http://mydomain.com/$1 permanent;
}

server {
listen 80;
server_name mydomain.com;
access_log /home/mydomain/logs/access.log;
error_log /home/mydomain/logs/error.log;
root /home/mydomain/public_html;

location / {
index index.html index.htm;
}

location ^~ /temp {
auth_basic "SP TEMP";
auth_basic_user_file /home/mydomain/htpasswd4;

location ~ \.(php|htm|html)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
}
}

location ^~ /admin {
auth_basic "SP Tech Dudes";
auth_basic_user_file /home/mydomain/htpasswd;

location ~ \.(php|htm|html)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
}
}

location ^~ /spadmin {
auth_basic "SP Dashboard";
auth_basic_user_file /home/mydomain/htpasswd2;

location ~ \.(php|htm|html)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
}
}


location ~ \.(php|htm|html)$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
}
}

server {
listen 80;
server_name resellers.mydomain.com;
access_log /home/mydomain/logs/resellers.access.log;

location / {
root /home/mydomain/public_html/resellers;
index index.html index.htm;
}

location ~ \.(php|htm|html)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html/resellers$fastcgi_script_name;
}
}

server {
listen 80;
server_name admin.mydomain.com;
access_log /home/mydomain/logs/admin.access.log;

location / {
root /home/mydomain/public_html/admin;
index index.html index.htm index.php;
}

location ~ \.(php|htm|html)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html/admin$fastcgi_script_name;
}

}

server {
listen 80;
server_name temp.mydomain.com;
access_log /home/mydomain/logs/temp.access.log;

location / {
root /home/mydomain/public_html/temp;
index index.html index.htm;
}

location ~ \.(php|htm|html)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html/temp$fastcgi_script_name;
}

}

Thank you,
Roger Remacle
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 195
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