The MU forums have moved to WordPress.org

nginx reverse proxy mode + wpmu + bp + supercache (5 posts)

  1. oldskoo1
    Member
    Posted 16 years ago #

    Ok - so i have high requirements :)

    I'm actually running fine on nginx as a reverse proxy with all the said components bolted to wpmu.

    I have 1 minor problem.

    I have wpmu setup to run as directories. My blog themes inherit the wrong stylesheet URL's. E.g.
    the style URL should be http://URL/wp-content/themes/mytheme/css/styles.css

    What nginx is doing is adding /member/ after the URL e.g.
    http://URL/*member*/wp-content/.... this obviously breaks any incldes.

    its using the bloginfo('stylesheet_url') to get this BTW.

    Well simple fix would be hardcode it. Yes that works, but buddypress plugin also has an ajax admin bar which has images / includes that are also affecting by nginx adding the /member/ name into the URL paths.

    So really this problem could span across many things.

    Does anyone who's hot on nginx have an idea on how i can stop nginx from putting the member name in the URL's of my blogs for includes / stylesheets.

    Funny thing is, it forwards all other non blog stuff to apache absolutly fine.

    Thanks,

  2. PerS
    Member
    Posted 16 years ago #

    Is a bit hard to help you without the nginx *.conf files

  3. oldskoo1
    Member
    Posted 16 years ago #

    Here is my nginx config for the site

    server {
    listen 80;
    server_name mydomain.co.uk;

    #access_log logs/host.access.log main;

    # Main location
    location / {
    proxy_pass http://127.0.0.1:8080/;
    proxy_redirect off;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    client_max_body_size 10m;
    client_body_buffer_size 128k;

    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;

    proxy_buffer_size 4k;
    proxy_buffers 4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;

    }

    # Static files location
    location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
    root /home/pathTOfiles/public_html;
    }

    if (-f $request_filename) {
    break;
    }

    if (-d $request_filename) {
    break;
    }

    set $supercache_file ”;
    set $supercache_uri $request_uri;

    if ($request_method = POST) {
    set $supercache_uri ”;
    }

    if ($query_string) {
    set $supercache_uri ”;
    }

    if ($http_cookie ~* “comment_author_|wordpress|wp-postpass_” ) {
    set $supercache_uri ”;
    }

    if ($supercache_uri ~ ^(.+)$) {
    set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
    }

    if (-f $document_root$supercache_file) {
    rewrite ^(.*)$ $supercache_file break;
    }

    }

    So, that config is putting the member name in the URL to stylesheets when viewing a members blog at http://URL/dan/ it thinks the includes should have dan in the path like http://URL/dan/wp-content/themes/mytheme/css/styles.css

    Apache doesn't do this.

  4. ajquigley
    Member
    Posted 16 years ago #

    I had the same problem with the blog name in the stylesheet and image file names. I added a rewrite rule

    location ~ ^/(.*)/wp-content/(.*)
    {
         rewrite  ^/(.*)/wp-content/(.*) /wp-content/$2 last;
    }

    and the stylesheets and images from my plugins and themes show up properly. But I'm still figuring out what to do with the same problem for the /BLOG/wp-admin/ directory.

  5. ajquigley
    Member
    Posted 16 years ago #

    OK, wp-admin works the same way. I was able to cover all the wp-* directories with one rewrite:

    location ~ ^/([_0-9a-zA-Z]+)/wp-([a-z]+)/(.*) {
        rewrite ^/([_0-9a-zA-Z-]+)(/wp-.*)$ $2 last;
    }

    Now my themes show up properly, and plugins and dashboards work right too.

About this Topic

  • Started 16 years ago by oldskoo1
  • Latest reply from ajquigley