formwork icon indicating copy to clipboard operation
formwork copied to clipboard

NGINX - admin forbidden

Open wsokc opened this issue 3 years ago • 5 comments

Hi,

When I try to install, the admin folder was forbidden, I'm using nginx, any ideas how to solve this ?

wsokc avatar Feb 28 '22 03:02 wsokc

Hello @wsokc,

currently I haven't done so many attempts to use Formwork with nginx, I'm not used to its config syntax too. Have you found a solution eventually?

giuscris avatar Mar 11 '22 20:03 giuscris

I agree with this, I use only nginx as it is much easier than another web/proxy server, all in one bottle!

TOWUK avatar Jun 04 '22 10:06 TOWUK

haven't invented the configuration for nginx yet?

TOWUK avatar Jun 25 '22 17:06 TOWUK

Hi @wsokc and @TOWUK, I've tried this nginx config. It's working by now, assuming you've already configured php-fpm. I'm still fine tuning it, let me know if it works for you.

server {
    index index.html index.php;

    # Adjust port and server name to your needs
    listen 8088;
    server_name localhost;

    # Adjust web root to your needs
    root /usr/local/var/www;

    charset utf-8;

    # Disable access to directory indexes
    autoindex off;

    location /site/templates/assets/ {
    }

    location ~ "^/admin/(assets|avatars)/.*" {
    }

    location / {
        # Prevent direct access to Formwork folders but allow access to assets
        rewrite ^/(admin|backup|cache|formwork|site|vendor)/.* /index.php last;

        # Prevent access to specific files
        rewrite ^/(.*)\.(md|yml|json)/?$ /index.php last;
        rewrite ^/(\.(.*)|LICENSE|composer\.lock)/?$ /index.php last;

        # Let all URI be processed by index.php
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        # Adjust PHP-FPM port to your needs 
        fastcgi_pass 127.0.0.1:9000;

        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        include fastcgi_params;
    }
}

giuscris avatar Jul 30 '22 09:07 giuscris

this dont work (admin panel) image

TOWUK avatar Aug 06 '22 17:08 TOWUK