Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Stato74's avatar

Laravel, Azure App Gateway, Docker Containers ... oh my !

Hi all, I'm struggling with some routing and URL setting in my Laravel Application

My application is hosted in a Docker container The Docker Container is then Pushed up to an Azure application service via an Azure Container Registery The App service has a private endpoint Traffic to the site comes through an Azure Application Gateway

In my example

The domain from the outside is https://laravel.mysite.co.uk/myappservice

I have a rewrite rule that redirects to myappservice.azurewebsites.net

I'm struggling with what my Laravel APP_URL should be in my ENV as my links are displaying e.g https://myappservice.azurewebsites.net/about which is inaccessbile and they need to be e.g. https://laravel.mysite.co.uk/myappservice/about

This is also messing up my css as some paths giving a 404

Any help would be great, but what am I missing ?

0 likes
3 replies
LaryAI's avatar
Level 58

To address the issue you're facing with the APP_URL in your Laravel application, you need to ensure that the APP_URL in your .env file is set to the external URL that users will access, which in your case is https://laravel.mysite.co.uk/myappservice.

Here are the steps to resolve the issue:

  1. Update the .env file: Set the APP_URL in your .env file to the external URL that includes the path /myappservice.

    APP_URL=https://laravel.mysite.co.uk/myappservice
    
  2. Update the config/app.php file: Ensure that the url configuration in config/app.php is set to use the APP_URL from the environment file.

    'url' => env('APP_URL', 'https://laravel.mysite.co.uk/myappservice'),
    
  3. Handle URL Generation: Laravel uses the APP_URL to generate URLs for assets, routes, and other links. By setting the APP_URL correctly, Laravel will generate the correct URLs.

  4. Clear Configuration Cache: If you have cached your configuration, you need to clear it so that the changes take effect.

    php artisan config:cache
    
  5. Check Rewrite Rules: Ensure that your Azure Application Gateway rewrite rules are correctly set up to forward requests to your Docker container. The rewrite rules should not alter the path structure that Laravel expects.

  6. Asset URLs: If you are using Laravel Mix or any other asset management tool, ensure that the URLs generated for your CSS and JS files are correct. You might need to update the mix configuration if necessary.

    For example, in webpack.mix.js:

    mix.setResourceRoot('/myappservice/');
    

By following these steps, your Laravel application should generate URLs that include the /myappservice path, ensuring that links and assets are correctly referenced.

If you continue to experience issues, you might want to check the following:

  • Ensure that there are no hardcoded URLs in your views or assets that do not include the /myappservice path.
  • Verify that the Azure Application Gateway is correctly forwarding the requests without altering the expected paths.

This should resolve the issue with incorrect URLs being generated in your Laravel application.

1 like
Stato74's avatar

i'm using vite could you tell me the vite equalivant of the webpack.mix.js: mix.setResourceRoot('/myappservice/');

Stato74's avatar

export default defineConfig({ base: '/myappservice/', // other configurations });

Please or to participate in this conversation.