Laravel代客安装(Nginx)与CMS(Perch Runway)

I'm attempting to set up Perch Runway on Valet. Looking at the documentation Perch Runway CAN run on Nginx setup which Valet uses. It used to be the case that you needed a custom Valet driver to achieve this but you no longer do. I have set up a new Valet instance and I can get to the Perch Admin without issue but... I get a 404 when viewing the frontend site.

I suspect that I need to set some rewrite rules in the Valet Nginx config file (similar to the required config in a .htaccess file) as per the perch documentation. I have attempted to use the Perch nginx config info to make amends to the valet config file for the site but the solution escapes me and I still see variouse 404, 403 errors depending on what I try after restarting Valet. I'm hoping someone with a bit more experience can see the solution.

Thanks in advance...

Things to Note:

  • the "perch" folder in the root has been renamed to "login".

Documentation Below

  • Old Perch Runway .htaccess config for reference
  • The Recommended Nginx Perch Config as per official documentation
  • My Valet Nginx Config File (without amends)
  • My Valet Nginx Config File (with attempted amends that don't work)

Old Perch Runway .htaccess config for reference

 RewriteCond %{REQUEST_URI} !^/login
 RewriteCond %{REQUEST_FILENAME} !-f

The Recommended Nginx Perch Config

# Match just the homepage
location = / {
    try_files $uri @runway;
}

# Match any other request
location / {
    try_files $uri $uri/ @runway;
}

# Perch Runway
location @runway {
    rewrite ^ /perch/core/runway/start.php last;
}

My Valet Nginx Config File (without amends)

  server {
      listen 80;
      server_name armstrong.test www.armstrong.test *.armstrong.test;
      return 301 https://$host$request_uri;
  }

  server {
      listen 443 ssl http2;
      server_name armstrong.test www.armstrong.test *.armstrong.test;
      root /;
      charset utf-8;
      client_max_body_size 128M;

      location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
          internal;
          alias /;
          try_files $uri $uri/;
      }

      ssl_certificate /Users/danlee/.valet/Certificates/armstrong.test.crt;
      ssl_certificate_key /Users/danlee/.valet/Certificates/armstrong.test.key;

      location / {
          rewrite ^ /Users/danlee/.composer/vendor/laravel/valet/server.php last;
      }

      access_log off;
      error_log /Users/danlee/.valet/Log/nginx-error.log;

      error_page 404 /Users/danlee/.composer/vendor/laravel/valet/server.php;

      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/Users/danlee/.valet/valet.sock;
          fastcgi_index /Users/danlee/.composer/vendor/laravel/valet/server.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME /Users/danlee/.composer/vendor/laravel/valet/server.php;
      }

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

My Valet Nginx Config File (with attempted amends that don't work)

    server {
        listen 80;
        server_name armstrong.test www.armstrong.test *.armstrong.test;
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl http2;
        server_name armstrong.test www.armstrong.test *.armstrong.test;
        root /;
        charset utf-8;
        client_max_body_size 128M;

        location /41c270e4-5535-4daa-b23e-c269744c2f45/ {
            internal;
            alias /;
            try_files $uri @runway;
        }

        ssl_certificate /Users/danlee/.valet/Certificates/armstrong.test.crt;
        ssl_certificate_key /Users/danlee/.valet/Certificates/armstrong.test.key;

        # Match any other request
           location / {
               try_files $uri $uri/ @runway;
           }

           # Perch Runway
           location @runway {
               rewrite ^ /perch/core/runway/start.php last;
           }

        location / {
            rewrite ^ /Users/danlee/.composer/vendor/laravel/valet/server.php last;
        }

        access_log off;
        error_log /Users/danlee/.valet/Log/nginx-error.log;

        error_page 404 /Users/danlee/.composer/vendor/laravel/valet/server.php;

        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/Users/danlee/.valet/valet.sock;
            fastcgi_index /Users/danlee/.composer/vendor/laravel/valet/server.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /Users/danlee/.composer/vendor/laravel/valet/server.php;
        }

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