0

I am using the laravel-localization package to localize my Laravel app. It works perfectly normal on local enviroment (using php artisan serve) and on shared hosting with Apache.

I've just deployed it on a VPS using Dokku, and I am getting 404's on every page that is localized. Other parts of the app work perfectly without issues.

Buildpacks:

https://github.com/heroku/heroku-buildpack-php
https://github.com/heroku/heroku-buildpack-nodejs

Procfile

web: vendor/bin/heroku-php-nginx -C nginx.conf -i php.ini public/
worker: php artisan queue:work --timeout=60 --sleep=3 --tries=3 --queue=high,default

nginx.conf

client_max_body_size 200M;
location / {
    index index.php;
    try_files $uri /index.php$is_args$args;
}

I discussed this already a bit with Dokku maintainers, and it seems that the PHP Buildpack uses the host nginx (nginx.conf.sigil) and the container nginx. Since I'm overwriting the container one in the procfile, I am guessing the issue lies in the host nginx somehow not letting the correct request through?

The .htaccess I deployed with which worked looks like this:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Handle X-XSRF-Token Header
    RewriteCond %{HTTP:x-xsrf-token} .
    RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

I'd appreciate any insight about what configuration is preventing the localized stuff to get loaded properly. I've already checked the enviroment variables, config ... and it's all identical on the server - the issue is definitely routing e.g. NGINX.

2
  • Just to point out that nginx does not use .htaccess at all because that is apache specific. If you are relying on .htaccess for your page to work correctly you will need to convert that to something that can be placed inside your nginx.conf file. This does not relate to this specific issue you have with localisation, it's just a general observation Commented 22 hours ago
  • @apokryfos i am aware of that - I just pasted the .htaccess to give a better comparison of the existing NGINX config to something that already worked with Apache... Commented 22 hours ago

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.