Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGINX - admin forbidden #263

Open
wsokc opened this issue Feb 28, 2022 · 5 comments
Open

NGINX - admin forbidden #263

wsokc opened this issue Feb 28, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@wsokc
Copy link

wsokc commented Feb 28, 2022

Hi,

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

@giuscris
Copy link
Member

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 giuscris added the help wanted Extra attention is needed label Mar 11, 2022
@TOWUK
Copy link

TOWUK commented Jun 4, 2022

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

@TOWUK
Copy link

TOWUK commented Jun 25, 2022

haven't invented the configuration for nginx yet?

@giuscris
Copy link
Member

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;
    }
}

@TOWUK
Copy link

TOWUK commented Aug 6, 2022

this dont work (admin panel)
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants