Skip to:
Content
Pages
Categories
Search
Top
Bottom

nginx re-write rules

  • Avatar of Ben (oldskoo1)
    oldskoo1
    Participant

    @oldskoo1

    Hello,

    I’m having trouble getting the re-write rules to work in nginx for wpmu + bp.

    Various problems, no input file specified, page not found etc, missing images/style sheets etc.

    Does anyone else here run nginx that could share their rules please.

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • I’m using this one (found it on mu.wordpress.org/forums). I’m having problems creating new blogs, but I’m not sure if it’s nginx causing the problem (it works fine with wpmu):

    server
    {

    listen 80;
    server_name DOMAIN.COM *.DOMAIN.COM;

    access_log /usr/local/nginx/logs/DOMAIN.COM.access.log;
    error_log /usr/local/nginx/logs/DOMAIN.COM.error.log;

    # rewrite rule for files

    location ~* ^.+.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$
    {
    root /home/web/DOMAIN.COM/www;
    rewrite ^/files(/.*)$ /wp-content/blogs.php?file=$1 last;
    expires 10d;
    break;
    }

    # rewrite rule for sitemap under the lines that handles upload files

    rewrite ^(.*/)?sitemap.xml wp-content/sitemap.php;

    # rewrite errors

    location /
    {
    #auth_basic "Restricted";
    #auth_basic_user_file /etc/nginx/htpasswd;
    root /home/web/DOMAIN.COM/www;
    index index.php;
    error_page 404 = /index.php?q=$uri;
    }

    #send php requests to fast cgi

    location ~ .php$
    {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/web/DOMAIN.COM/www$fastcgi_script_name;
    include /usr/local/nginx/conf/fastcgi_params;
    }

    }

    Avatar of Nicola Greco
    nicolagreco
    Participant

    @nicolagreco

    @pers

    if it works for you add that in the codex! :)

    For new blogs you’ve to edit your dns zone adding *.yourdomain.com. IN A YO.UR.IP

    and add an alias in config

    nicola, I’ll add it when I know it’s working fine with buddypress. the config above works fine om my wpmu site, but as I said, I’m having problems with a buddypress site. The “problem” is that it’s not creating any errors I can use for debugging (and before you suggest that I should log errors .. I’m do that :)

    I belive I found the bug :) running domain/wp-signup.php worked but domain/members/USER/blogs/create-a-blog didn’t. I suspected the error_page 404 = /index.php?q=$uri; directive and changing that fixed the problem. I changed it to:

    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
    }

    The comple working DOMAIN.conf is:

    server
    {

    listen 80;
    server_name DOMAIN.COM *.DOMAIN.COM;

    access_log /usr/local/nginx/logs/DOMAIN.COM.access.log;
    error_log /usr/local/nginx/logs/DOMAIN.COM.error.log;

    # rewrite rule for files

    location ~* ^.+.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$
    {
    root /home/web/DOMAIN.COM/www;
    rewrite ^/files(/.*)$ /wp-content/blogs.php?file=$1 last;
    expires 10d;
    break;
    }

    # rewrite rule for sitemap under the lines that handles upload files

    rewrite ^(.*/)?sitemap.xml wp-content/sitemap.php;

    # rewrite errors

    location /
    {
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/htpasswd;
    root /home/web/DOMAIN.COM/www;
    index index.php;
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
    }
    }

    #send php requests to fast cgi

    location ~ .php$
    {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/web/DOMAIN.COM/www$fastcgi_script_name;
    include /usr/local/nginx/conf/fastcgi_params;
    }

    }

    forgot to remove the lines protecting my site, you should remove:

    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/htpasswd;

    Avatar of Ben (oldskoo1)
    oldskoo1
    Participant

    @oldskoo1

    Awesome, i binned nginx because i was having problems!

    I will get it back on my server and give this a go.

    Thank you

    Avatar of Indojepang
    Indojepang
    Participant

    @indojepang

    Helloo sorry bringing up the dead.. but still no luck with Nginx.. is there any fix one?

    my buddypress is fine but in the backend of WPMU administration has “no input specified”.

    WPMU 2.7.1

    buddypress 1.02

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    @Indojepang

    This is not a BuddyPress issue nor a WPMU issue. It has to do with properly setting up a Nginx web server. But, your best bet is to go search the WPMU forums. If you can’t find an answer, post a new thread.

    Avatar of andrew09
    andrew09
    Participant

    @andrew09

    hi guys were you able to include supercache in the conf/vhost? thanks a lot

    Avatar of andrew09
    andrew09
    Participant

    @andrew09

    hi everyone, i tried installing mu via SVN but I couldn’t get to the index page. It’s giving me a 502 error “bad gateway”. Portion of the error logs:

    2009/08/09 09:16:45 [error] 1160#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: IP.XXX.XXX.XXX, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com"
    2009/08/09 09:16:45 [error] 1160#0: *7 open() "/home/public_html/mydomain.com/public/favicon.ico" failed (2: No such file or directory), client: IP.XXX.10X.1XX, server: mydomain.com, request: "GET /favicon.ico HTTP/1.1", host: "mydomain.com"

    basically… Connection refused, and favicon

    HELP! :( THanks

    Avatar of andrew09
    andrew09
    Participant

    @andrew09

    hey guys! it’s all good now, i forgot to install spawn-fcgi

    http://redmine.lighttpd.net/projects/spawn-fcgi/wiki/Build

    hope this could be of help for future nginx enthusiasts.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘nginx re-write rules’ is closed to new replies.