Mass virtual hosting and global redirect
Edho P Arief
edhoprima at gmail.com
Thu Jun 18 17:13:17 MSD 2009
On Tue, Jun 16, 2009 at 10:06 PM, NoSync<nginx-forum at nginx.us> wrote:
> This is the whole conf:
>
> nginx.conf:
>
> user www-data;
> worker_processes 1;
>
> error_log /var/log/nginx/error.log;
> pid /var/run/nginx.pid;
>
> events {
> worker_connections 1024;
> }
>
> http {
> include /etc/nginx/mime.types;
> default_type application/octet-stream;
>
> access_log /var/log/nginx/access.log;
>
> sendfile on;
> tcp_nopush on;
> tcp_nodelay off;
> keepalive_timeout 3;
>
> gzip on;
> gzip_comp_level 1;
> gzip_proxied any;
> gzip_min_length 1024;
> gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
>
> include /etc/nginx/conf.d/*.conf;
> include /etc/nginx/sites-enabled/*;
> }
>
> and this is the enabled server file:
>
> server {
> listen 80;
> server_name ~^[^.]+\.[^.]+$; # domain.com
> rewrite ^ http://www.$host$request_uri?;
> }
>
> server {
> listen 80 default;
> server_name ~^(.*)\.(.*\..*)$;
> set $sub $1;
> set $domain $2;
> root /var/www/vhosts/$domain/$sub;
> access_log /var/log/nginx/access.log combined;
> error_log /var/log/nginx/error.log error;
>
> include /etc/nginx/conf/wordpress_params;
>
> location / {
> root /var/www/vhosts/$domain/$sub;
> index index.php index.html;
>
> if (-f $request_filename) {
> expires 30d;
> break;
> }
>
> if (!-e $request_filename) {
> rewrite ^(.*)$ /index.php?q=$1 last;
> break;
> }
> }
>
> location ~* i.+\.(css|js|jpg|jpeg|gif|png)$ {
> expires 7d;
> }
>
> location ~ "^(.+\.php)($|/)" {
> include /etc/nginx/fastcgi_params;
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_index index.php;
> }
>
> location ~ /\.ht {
> deny all;
> }
> }
>
> and here's the wordpress_params file which is also included:
>
> if (-f $request_filename) {
> break;
> }
>
> set $supercache_file '';
>
> set $supercache_uri $request_uri;
>
> if ($request_method = POST) {
> set $supercache_uri '';
> }
>
> # Using pretty permalinks, so bypass the cache for any query string
> if ($query_string) {
> set $supercache_uri '';
> }
>
> if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
> set $supercache_uri '';
> }
>
> # if we have not bypassed the cache, specify our supercache file
> if ($supercache_uri ~ ^(.+)$) {
> set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
> }
>
> # only rewrite to the supercache file if it actually exists
> if (-f $document_root$supercache_file) {
> rewrite ^(.*)$ $supercache_file break;
> }
>
> # all other requests go to Wordpress
> if (!-e $request_filename) {
> rewrite . /index.php last;
> }
>
> Unfortunately I can't recompile and install with debug flags right now as this is a production server. :-/
you can -
just install to different path
--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
More information about the nginx
mailing list