mardi 5 avril 2022

laravel - can not change base URL in Docker + Laravel PHP + Nginx

I try to migrate my backend website (containing API service to mobile apps) from LAMP into docker platform. currently this docker split into 3 parts (Laravel App, database & nginx). sofar, the website launch successfully without error.

However, I need base URL to be like below:

http://backend.example.com/public/

so, if i want to login, url will be http://backend.example.com/public/login, also API url with above format like http://backend.example.com/public/api/v1

What I have tried:

  1. Set APP_URL value in .env to http://backend.example.com/public/
  2. Set below setting in config/app.php to:
'url' => env('APP_URL', 'https://backend.example.com/public'),
'asset_url' => env('ASSET_URL', null)
  1. run php artisan route:clear and php artisan migrate

but still not successfull, evertime i launch web browser, url still stuck to:

http://backend.example.com/

http://backend.example.com/login/

http://backend.example.com/api/v1/

etc

any idea to overcome above problem?

===Additional Note

  1. nginx conf for nginx docker:
server {
    listen 80;
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/public;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}
  1. original base URL in LAMP are http://backend.example.com/public/, in original i'm using LAMP (Apache+PHP+MySQL) but in current Docker I'm using (Nginx + MySQL + php:7.4-fpm), however because an error, i change something so original base url cannot be achieved anymore...

  2. Reference of This Migration can be found here.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/P3N40Va
via IFTTT

Aucun commentaire:

Enregistrer un commentaire