HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Vanilla 3.3 in sub directory on Buster with nginx

Sorry if my problems was solved somewhere on the forums and I didn't find it. I am trying since hours to get Vanilla 3.3 running. Neither one of the many posts here nor the docs helped. Most of the posts refer to the old style URLs with ?p=...

I still had an old Vanilla 2.3 running and want to upgrade it to 3.3. Followed the upgrade steps from the docs and installed the new files, but I am stuck at the point where I need to trigger the database update.

The problem is that Vanilla is located in a subdirectory called community on the server (in the root there is a Grav site). No matter what I try I cannot get the redirects for Vanilla to work with nginx (having a redirection loop). Also found the docker sample configs in the vanilla git repo, but even those didn't help.

Does perhaps anybody here have Vanilla 3.3 running from a subdirectory (with other php files on the server as well) and would be so nice to share his/her configuration?

Any help is appreciated! Many thanks in advance!

Best!

Comments

  • Could you paste the parts of your nginx config that relate to Vanilla here?

  • K17K17 ✭✭✭
    edited February 2021

    That documentation didn't helped me when I needed to install Vanilla on nginx.... It's very confusing. And actually it didn't worked at all. Had to use index.php?p=.

    Then moved aways and used apache2.

  • skmskm New
    edited February 2021

    Hi,

    thanks a lot for trying to help. Somehting is very wrong and I don't get what is happening. It does work now, BUT only with the old index.php?p= redirect. I understood from the upgrade page, that this shouldn't work anymore?!?

    Upgrading my old installation with following the upgrade steps in the docs and copying the database and user data over didn't work, neither. Perhaps due to some old plugin. Setting up a new install and copying the data over seems to work, but only with the old redirect.

    I would actually have this working with the new redirect version, but I cannot get it to work properly (always ending with a redirect loop). Perhaps after reading all those posts and docs and trying out so many things, I couldn't see the forrest for the trees anymore.

    This is what I have now. Do you have any hint how to fix this for the new redirect?

    Many thanks for your help! It is highly appreciated.

       location ~* /community/\.git { deny all; return 403; }
       location /community/build/ { deny all; return 403; }
       location /community/cache/ { deny all; return 403; }
       location /community/cgi-bin/ { deny all; return 403; }
       location /community/uploads/import/ { deny all; return 403; }
       location /community/conf/ { deny all; return 403; }
       location /community/tests/ { deny all; return 403; }
       location /community/vendor/ { deny all; return 403; }
       
       location /community {
           try_files $uri @vanilla;
       }
    
      location @vanilla {
           rewrite ^/community(/.*) /community/index.php?p=$1&$args last;
      }
    


  • skmskm New
    edited February 2021

    Hi Kaspar,

    thanks a lot for your help! Unfortunately it doesn't solve the initial problem. My above snippet does work - somewhat surprisingly, because the docs say, that the index.php?p= variant isn't supported anymore. Instead of the "p=" redirection, there should be used an alternative version now and since this one here shouldn't be working anymore, I fear that some future update might break my forums. So I am looking for a solution to set this up properly as it is described in the docs (this is actually what is commented out in your solution). But unfortunately, no matter what I try, it doesn't work.

    Please don't get me wrong. I highly appreciate your help! You solution just doesn't fit my problem ☺️

  • KasparKaspar ✭✭✭

    "Please don't get me wrong."

    Not at all :-)

    To my knowledge "index.php?p=" not being supported means you are required to have pretty urls enabled and hence a rewrite.



    I have no nginx experience and rewrite rules aint my thing.

    But from this:

    rewrite ^/(.+)$ /index.php?p=$1 last;
     }
    

    I would expect yours to be

    rewrite ^/community(.+)$ /community/index.php?p=$1 last;
     }
    


  • This is really confusing. I understood that the docs specifically refer to the above redirect with the ?p=$1 rewrite. This does work on my server, even without the prettyurls setting enabled.

    But the variant that they suggest in the docs:

    # This handles all the main requests thru index.php.
        location ~* ^/index\.php(/|$) {
            # send to fastcgi
            include fastcgi.conf;
            fastcgi_param SCRIPT_NAME /index.php;
            fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
            fastcgi_param X_REWRITE 1;
            fastcgi_pass php-fpm; # where 'php-fpm' is the upstream, probably defined in nginx.conf 
        }
    
        # If this is some other PHP script, disallow it by redirecting to /index.php
        location ~* \.php(/|$) {
            rewrite ^ /index.php$uri last;
        }
    
        # Default path handling
        location / {
            try_files $uri @vanilla;
        }
        
        location @vanilla {
            rewrite ^ /index.php$uri last;
        }
    
    

    This is what I cannot get to work in a subdirectory...

    This is what they say in the upgrade docs. Perhaps it is misleading and has nothing to do with the redirect?!? Although this doesn't seem to make sense 😕

    If your forum still uses URLs including ?p=, support for this URL structure has ended. Follow these steps to switch to the simpler format:

    Confirm your server is setup to handle rewrites. On Apache, using the .htaccess file provided will accomplish this. Additional setup is required on nginx and other platforms.

    Test whether it is working by visiting /discussions - if you see a discussions list (rather than a 404), it is likely setup correctly.

    Open /conf/config.php and find the line with $Configuration['Garden']['RewriteUrls'] = false; and delete the entire line.


    Thanks!!!

  • K17K17 ✭✭✭

    About the

    Open /conf/config.php and find the line with $Configuration['Garden']['RewriteUrls'] = false; and delete the entire line.

    I do agree with you, actually if RewriteUrls config is not set, it will not use pretty urls. Set it to true instead.

    And I have not much knowledge in nginx to help you :/

  • You have a small regex problem in your first try. Try this one:


       location @vanilla {
           rewrite ^/community/(.+)$ /community/index.php?p=$1 last;
       }
    


Sign In or Register to comment.