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

Working nginx config for a subdirectory install #2747

Closed
EugeneDae opened this issue Feb 19, 2023 · 5 comments
Closed

Working nginx config for a subdirectory install #2747

EugeneDae opened this issue Feb 19, 2023 · 5 comments

Comments

@EugeneDae
Copy link

EugeneDae commented Feb 19, 2023

According to #1005 and #1610 FreeScout supports subdirectory installation (e.g. https://example.com/freescout/ instead of https://freescout.example.com), however if I use the nginx config from the Installation Guide I cannot get nginx to serve static files without breaking FreeScout's routing.

Here's my current nginx config:

server {
    ...
    
    root /var/www/freescout/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

...and here's what it gets me:
01
02

This is what I've tried:

server {
    ...
    root /var/www/freescout/public;
    index index.php index.html;

    location /freescout {
        alias /var/www/freescout/public;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        fastcgi_index index.php;
        # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        include fastcgi_params;
    }
}

It fixes static files but breaks the routing:
03
04

Interestingly, in this case (if I clear the cookies) /freescout/login/ works correctly:
05

(The APP_URL parameter in the .env file is set correctly).

I'm thinking I need a rewrite somewhere, but I wonder what is the recommended way of solving this? Any tips would be appreciated.

@freescout-helpdesk
Copy link
Contributor

What's your APP_URL value?

@EugeneDae
Copy link
Author

What's your APP_URL value?

APP_URL=https://my.domain.io/freescout

Without the trailing slash, but if I add it, it makes no difference.

@EugeneDae
Copy link
Author

This seems to work:

server {
    ...

    location /freescout {
        alias /var/www/freescout/public;
        try_files $uri /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}

@freescout-helpdesk
Copy link
Contributor

Thanks. Can you share your full nginx config, so that we can add it to the Installation Guide.

@EugeneDae
Copy link
Author

@freescout-helpdesk

This is almost full configuration that I'm using right now, without server_name and SSL stuff, and I don't know yet how to adapt other "locations" from the Installation Guide (location ~* ^/storage/attachment/ etc). That's why I asked if there's an official recommendation.

Seeing my installation is new and clean, I'd like to test it more. Meanwhile I suggest that you link this issue in the Installation Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants