Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Please upgrade here. These earlier versions are no longer being updated and have security issues.

How to configure Nginx for Vanilla Forums 2.3?

First, thank you for this new PHP7 compatible Vanilla 2.3. I installed it but could not make it work with Nginx. I read this page in the docs: http://docs.vanillaforums.com/developer/backend/ but it didn’t help me. Do you know more about how to configure Nginx with Vanilla 2.3?
Here are my location blocks:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

http://stackoverflow.com/questions/41152714/how-to-configure-nginx-for-vanilla-forums-2-3

Comments

  • LincLinc Director of Development Detroit Vanilla Staff
    edited December 2016

    This is a simplified version of my nginx.conf file, inside the http { block:

    server {
        listen       80 default_server;
        listen       8080 default_server;
        server_name  ~^(www\.)?(?<domain>.*)\.(dev|test)$;
        root         /www/$domain;
        index        index.html index.htm index.php;
        rewrite_log on;
    
        ## PHP handler
        location ~* \.php$ {
            # turn off caching for php
            expires -1;
            # send to fastcgi
            include fastcgi_params;
            fastcgi_pass backend;
        }
    
        location @site {
           rewrite ^ /index.php?p=$uri&$args last;
        }
    
        location ~ /\.ht {
            deny  all;
        }
    
        location / {
           try_files $uri @site;
        }
    }
    
    upstream backend {
       server 127.0.0.1:9000;
    }
    
  • LincLinc Director of Development Detroit Vanilla Staff
    edited December 2016

    I should add that this is not my area of expertise at all. I don't have a great depth of knowledge about nginx, just enough to keep my localhost mostly working despite the crazy number of edge cases I test with it (hence needing to simplify it before sharing; hopefully without breaking it).

    The ?p= rewrite is no longer necessary in 2.3 afaik. However, I run versions of Vanilla back to 2.0 on my localhost so I cannot remove it entirely, hence using it as a fallback.

  • ShadowdareShadowdare π Moderator

    Add Pages to Vanilla with the Basic Pages app | Publish articles with the Articles app

  • sashaesashae New
    edited December 2016

    If the ?p= rewrite is no longer necessary in 2.3, what /should/ it be -- I'm getting blank white pages when attempting to rewrite from /path/name to /path/index.php?name (I'm running in a subdir.)

  • location @site { rewrite ^/path(.+)$ /path/index.php?p=$1&$args last; }

    ...worked correctly in 2.2.

  • Rewrite logs give me:

    2016/12/16 12:05:36 [notice] 19744#19744: *161 "^/path(.+)$" matches "/path/utility/update", client: 1.2.3.4, server: host.name, request: "GET /path/utility/update HTTP/1.1", host: "host.name" 2016/12/16 12:05:36 [notice] 19744#19744: *161 rewritten data: "/path/index.php", args: "p=/utility/update&", client: 1.2.3.4, server: host.name, request: "GET /path/utility/update HTTP/1.1", host: "host.name"

    ...but I get nothing but blank white screen.

  • Bah. My fault, php problem rather than a Vanilla problem. Config works as expected.

  • Hi all,

    Bumping this old thread. @Linc if we're on a shared server without access to nginx.conf, is there a way to get vanilla to work with nginx?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    That should be no problem, but without access to the server configuration, you will not be able to use pretty urls.

    Before installing, but already after unzipping the files, you need to search for $Configuration['Garden']['RewriteUrls'] = true; in the /conf/config-default.php and change that to $Configuration['Garden']['RewriteUrls'] = false;.

    After the installation there will be a file called /conf/config.php where you should add this setting, too. Otherwise the next upgrade would overwrite this changed default configuration and your forum wouldn't work until you re-do this change. Therefore you should simply add it to the config.php right after the installation and afterwards you can simply forget about it.

  • @R_J said:
    That should be no problem, but without access to the server configuration, you will not be able to use pretty urls.

    Before installing, but already after unzipping the files, you need to search for $Configuration['Garden']['RewriteUrls'] = true; in the /conf/config-default.php and change that to $Configuration['Garden']['RewriteUrls'] = false;.

    After the installation there will be a file called /conf/config.php where you should add this setting, too. Otherwise the next upgrade would overwrite this changed default configuration and your forum wouldn't work until you re-do this change. Therefore you should simply add it to the config.php right after the installation and afterwards you can simply forget about it.

    Thanks @R_J for the reply. Was going to migrate over my current installation (which has pretty URLs) to this new host, but now I think I need to find a new host. I don't want to lose the SEO I have going.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Maybe writing them a mail and explaining your problem would help. If your hoster is a good service provider, they will be able to help

  • Yeah not so much..

    "Thank you for contacting us.

    It does seem appear to be related to that temporary IP URL and the rewrite rule, so the Sign In or Register do not work properly as expected.

    I'm afraid customers on shared hosting servers won't have access to update the nginx.conf file, and this file can't be changed per customers requests either , as this can affect other customers on this same sever.

    I would suggest you to check with the Vanilla forum's community or their developers, and see if there's anything that can be done/setup in the .htaccess file to solve such issues.

    Let us know again if we can assist you any further."

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    That's an answer which would really scare me!
    https://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/

    Unless they are doing some magic, changing the .htaccess is useless.

Sign In or Register to comment.