0

I have a live install with a primary domain of https://marketing.vessul.co/ which works great.

When I've added another site to this install and it's location is another folder such as /extra-site it works just like it's supposed to.

I'm having trouble adding a new site with a unique URL. The domain is pointed at the server and clearly responds to changes in my Forge config file. I can't get Craft to "switch" sites to the new one at the URL. The closest I've gotten is recognizing the new Base URL when I specify it in forge.

My primary site uses basically this exact config for static page caching: https://nystudio107.com/blog/static-caching-with-craft-cms

The following is the current config for the domain which is https://marketing-test.vessul.co/

Note: I've tried the full config I use at https://marketing.vessul.co as seen on NYstudio107 but I'm not seeing any chance other than the Base URL being recognized.

Has anyone had luck with getting craft multisite to work with Forge?

Thanks,

fastcgi_cache_path /var/run/nginx-cache/vessulmarketingtest levels=1:2 keys_zone=VESSULMARKETINGTEST:100m inactive=1d;


# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/marketing-test.vessul.co/before/*;

server {
    # Listen for both IPv4 & IPv6 requests on port 443 with http2 enabled
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # General virtual host settings
    server_name  marketing-test.vessul.co;
    root /home/forge/marketing.vessul.co/web;
    index index.html index.htm index.php;
    charset utf-8;

    # Enable server-side includes as per: http://nginx.org/en/docs/http/ngx_http_ssi_module.html
    ssi on;

    # Disable limits on the maximum allowed size of the client request body
    client_max_body_size 0;

    # Ban certain bots from crawling the site
    if ($limit_bots = 1) {
        return 403;
    }

    # 404 error handler
    error_page 404 /index.php?$query_string;

     #Cache everything by default
     fastcgi_cache_key "$scheme$request_method$host$request_uri";
       #add $abtest to do that (in fastcgi_cache_key)

    add_header X-Cache $upstream_cache_status;
     set $no_cache 0;
     if ($request_method = POST)
     {
         set $no_cache 1;
     }
     if ($request_uri ~* "/(admin/|cpresources/)")
     {
         set $no_cache 1;
     }

    # 301 Redirect URLs with trailing /'s as per https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
    rewrite ^/(.*)/$ /$1 permanent;
    
    # Change // -> / for all URLs, so it works for our php location block, too
    merge_slashes off;
    rewrite (.*)//+(.*) $1/$2 permanent;

    # Access and error logging
    access_log off;
    error_log  /var/log/nginx/marketing.vessul.co-error.log error;
    # If you want error logging to go to SYSLOG (for services like Papertrailapp.com), uncomment the following:
    #error_log syslog:server=unix:/dev/log,facility=local7,tag=nginx,severity=error;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/marketing-test.vessul.co/xxxxxx/server.crt;
    ssl_certificate_key /etc/nginx/ssl/marketing-test.vessul.co/xxxxxx/server.key;

    # SSL/TLS configuration, with TLSv1.0 disabled because it is insecure; note that IE 8, 9 & 10 support
    # TLSv1.1, but it's not enabled by default clients using those browsers will not be able to connect
    ssl_protocols TLSv1.2 TLSv1.1;
    ssl_prefer_server_ciphers on;
    # ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5';
    ssl_buffer_size 4k;
    ssl_session_timeout 4h;
    ssl_session_cache shared:SSL:40m;
    ssl_stapling on;
    ssl_stapling_verify on;
    # ssl_trusted_certificate /etc/nginx/ssl/lets-encrypt-x3-cross-signed.pem;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/marketing-test.vessul.co/server/*;

    # Load configuration files from nginx-partials
    include /etc/nginx/nginx-partials/*.conf;

    # Handle Do Not Track as per https://www.eff.org/dnt-policy
    location /.well-known/dnt-policy.txt {
        try_files /dnt-policy.txt /index.php?p=/dnt-policy.txt;
    }

    # For WordPress bots/users
    location ~ ^/(wp-login|wp-admin|wp-config|wp-content|wp-includes|(.*)\.exe) {
        return 301 https://wordpress.com/wp-login.php;
    }

    # Root directory location handler
    location / {
        try_files $uri/index.html $uri $uri/ /index.php?$query_string;
    }

    # Localized sites, hat tip to Johannes -- https://gist.github.com/johanneslamers/f6d2bc0d7435dca130fc

    # If you are creating a localized site as per: https://craftcms.com/docs/localization-guide
    # the directives here will help you handle the locale redirection so that requests will
    # be routed through the appropriate index.php wherein you set the `CRAFT_LOCALE`

    # Enable this by un-commenting it, and changing the language codes as appropriate
    # Add a new location @XXrewrites and location /XX/ block for each language that
    # you need to support

    #location @enrewrites {
    #    rewrite ^/en/(.*)$ /en/index.php?p=$1? last;
    #}
    #
    #location /en/ {
    #    try_files $uri $uri/ @enrewrites;
    #}

    # Craft-specific location handlers to ensure AdminCP requests route through index.php
    # If you change your `cpTrigger`, change it here as well
    location ^~ /admin {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ^~ /cpresources {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # php-fpm configuration for non-cached content
     location @phpfpm_nocache {
        try_files $uri $uri/ /index.php?$query_string;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # Change this to whatever version of php you are using
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTP_HOST marketing-test.vessul.co;

        # Don't allow browser caching of dynamically generated content
        add_header Last-Modified $date_gmt;
        add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
        if_modified_since off;
        expires off;
        etag off;

        # Use Dotenvy to generate the .env variables as per: https://github.com/nystudio107/dotenvy
        # and then uncomment this line to include them:
        # include /home/forge/dev.leslierotella/.env_nginx.txt

        fastcgi_param HTTP_PROXY "";
        fastcgi_param    ENVIRONMENT             "production";
        fastcgi_param    SECURITY_KEY            "key";
        fastcgi_param    DB_DRIVER               "mysql";
        fastcgi_param    DB_SERVER               "localhost";
        fastcgi_param    DB_USER                 "user";
        fastcgi_param    DB_PASSWORD             "pass";
        fastcgi_param    DB_DATABASE             "vessulmarketing";
        fastcgi_param    DB_SCHEMA               "public";
        fastcgi_param    DB_TABLE_PREFIX         "prefix";
        fastcgi_param    DB_PORT                 "3306";
        fastcgi_param SITE_URL                   "https://marketing-test.vessul.co/";
        fastcgi_param BASE_URL                   "https://marketing-test.vessul.co/";
        fastcgi_param BASE_PATH                  "/home/forge/marketing.vessul.co/web/";

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        # No FastCGI Cache
        fastcgi_cache_bypass 1;
        fastcgi_no_cache 1;
    }

    # php-fpm configuration
    location ~ [^/]\.php(/|$) {
        try_files $uri $uri/ /index.php?$query_string;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # Change this to whatever version of php you are using
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param HTTP_HOST marketing.vessul.co;

        # Use Dotenvy to generate the .env variables as per: https://github.com/nystudio107/dotenvy
        # and then uncomment this line to include them:
        # include /home/forge/dev.leslierotella/.env_nginx.txt

        fastcgi_param HTTP_PROXY "";
        fastcgi_param    ENVIRONMENT             "production";
        fastcgi_param    SECURITY_KEY            "key";
        fastcgi_param    DB_DRIVER               "mysql";
        fastcgi_param    DB_SERVER               "localhost";
        fastcgi_param    DB_USER                 "user";
        fastcgi_param    DB_PASSWORD             "pass";
        fastcgi_param    DB_DATABASE             "vessulmarketing";
        fastcgi_param    DB_SCHEMA               "public";
        fastcgi_param    DB_TABLE_PREFIX         "prefix";
        fastcgi_param    DB_PORT                 "3306";
        fastcgi_param SITE_URL                   "https://marketing-test.vessul.co/";
        fastcgi_param BASE_URL                   "https://marketing-test.vessul.co/";
        fastcgi_param BASE_PATH                  "/home/forge/marketing.vessul.co/web/";

        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        # FastCGI Cache settings
         fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
         fastcgi_cache VESSULMARKETINGTEST;
         fastcgi_cache_valid 200 1d;
         fastcgi_cache_use_stale updating error timeout invalid_header http_500;
         fastcgi_cache_bypass $no_cache;
         fastcgi_no_cache $no_cache;    
        }

    location ~ /\.ht {
        deny all;
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/marketing-test.vessul.co/after/*;

Settings in craft showing both sites: craft settings

8
  • Looks like fastcgi_param HTTP_HOST, SITE_URL among others should be changed to the test site. Commented Jun 19, 2020 at 18:07
  • Unfortunatly not @RitterKnight - I updated those fields as well as the 'BASE_URL' and all that is recognized now is the correct base url on this page marketing-test.vessul.co/test Any other fields you think I should try? Commented Jun 20, 2020 at 20:57
  • When you go into Settings -> Sites, there should be 2 base URLs correct? Commented Jun 21, 2020 at 19:40
  • That is correct @RitterKnight - I'm outputting the site information via this page in the docs on that test page: docs.craftcms.com/v3/sites.html#creating-a-site It has the correct Base URL but not everything else is wrong Commented Jun 21, 2020 at 20:31
  • Can you repost your full config? nginx -T from the command line will show you a dump of it. FWIW I'd probably comment out all the fastcgi_cache lines until you get the site developed or you'll go mad at why your changes aren't taking as well... I'm also not a fan of adding credentials or extra variables to your fastcgi_param params unless you have a very good reason to do so as it tends to make troubleshooting much harder. Commented Jun 21, 2020 at 20:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.