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

Updated nginx docs

2»

Comments

  • charrondevcharrondev Developer Lead (PHP, JS) Montreal Vanilla Staff

    @Gentle you could always make a pull request yourself. The docs are just markdown files in a open github repo.

  • edited November 2020

    bumping this thread.

    Did a clean installed today (not used Vanilla in 10 years 😯 )


    Nothing seems to happen

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
    
    
        ssl_certificate /etc/dehydrated/certs/domain.nz/fullchain.pem;
        ssl_certificate_key /etc/dehydrated/certs/domain.nz/privkey.pem;
    
    
        root /var/www/html/domain.nz;
    
    
        server_name www.domain.nz;
        access_log /var/log/nginx/domain.nz-access.log;
        error_log /var/log/nginx/domain.nz-error.log;
    
    
        location /.well-known/acme-challenge {
          alias /var/www/dehydrated;
        }
    
    
        index index.php;
    
        # Hardening
        location ~* "/\.git" { deny all; return 403; }
        location ~* "^/build/" { deny all; return 403; }
        location ~* "^/cache/" { deny all; return 403; }
        location ~* "^/cgi-bin/" { deny all; return 403; }
        location ~* "^/uploads/import/" { deny all; return 403; }
        location ~* "^/conf/" { deny all; return 403; }
        location ~* "^/tests/" { deny all; return 403; }
        location ~* "^/vendor/" { deny all; return 403; }
    
    
        # 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 unix:/var/run/php/php7.3-fpm.sock;
        }
    
    
        # 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;
        }
    }
    


    the front page loads.

    Then I click /discussion/1/welcome-to-awesome#latest and nothing.

    It's like my request vars aren't be passed to nginx??

    If I remove fastcgi_param X_REWRITE 1 the site works fine but uses /index.php?p=/discussion/1/welcome-to-awesome#latest


    Halp?

  • ok, after lots of trial and error here is what works

    in nginx conf

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

    and

    location ~* \.php(/|$) {
            # rewrite ^ /index.php$uri last;
            rewrite ^/(.+)$ /index.php?p=$1 last;
     }
    

    and then in conf/config.php add:

    $Configuration['Garden']['RewriteUrls'] = true;
    


  • Ok, another update.

    The website works as expected, but I have errors in the console.

    Could not find component subcommunity-chooser in /dist/forum/addons/rich-editor.min.js?h=3.3
    

    and

    DevTools failed to load SourceMap: Could not load content for /api/v2/sourcemaps/forum/sourcemaps/owkmw/1a0bc338758b545a618c: HTTP error: status code 403, net::ERR_HTTP_RESPONSE_CODE_FAILURE
    

    in fact /api doesn't work at all .. related to pretty urls and rewrite I bet

  • oh, I just looked at the console at open.vanillaforums.com .. it's full of 403 errors trying to access /api/v2 as well 🙄

  • R_JR_J Ex-Fanboy Munich Admin

    Well, no. "Subcimmunities" is a feature which is not available in the OS version of Vanilla. It's just an error or lazyness in packaging the OS version that there is still a reference to it

    If you can use the rich editor, your api is working and your server configuration isn't the problem.

    If you try to use the api by yourself and you are not successful, you might want to start a discussion about that.


    This is the nginx config file which is good enough in my VM environment (just as an information)

    server {
    
       listen 80;
       listen [::]:80;
    
       root /var/www/vanilla;
    
       # Add index.php to the list if you are using PHP
       index index.php;
    
       server_name vanilla.localhost;
    
       # Default path handling
       location / {
           try_files $uri @vanilla;
       }
    
       location @vanilla {
           fastcgi_param X_VANILLA 1;
           rewrite ^/(.+)$ /index.php?p=$1 last;
       }
    
       # pass PHP scripts to FastCGI server
       #
       location ~ \.php$ {
          include snippets/fastcgi-php.conf;
    
          # With php-fpm (or other unix sockets):
          fastcgi_pass unix:/var/run/php/php-fpm.sock;
       }
    
    }
    


  • thanks @R_J

    I'm going to try and get rid of the sub communities error.

    I hate errors in my console 🤣

  • actually that was quite easy:

    • themes/theme-boilerplate/views/partials/footer.tpl
    • themes/theme-boilerplate/views/partials/header.tpl
    • themes/keystone/views/default.master.tpl

    Remove references to {community_chooser}

Sign In or Register to comment.