Score:0

Using Docker to run a laravel app, I am getting content load from http, and not https

cn flag

I am dockerizing my laravel app, and when it loads, I get an error saying that mixed content cant be served. I look at source code of html page, and it does load the app.js file from http scheme, despite me being on https. When I install the same laravel app on my own nginx server with redirection to https, the app.js is rendered with https. So its not a thing with laravel. How do I make nginx conf inside Docker serve content to https? My current .conf file is this:

server {
    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html/public;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1: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;
    }
}


vn flag
You likely need to tell Laravel to trust the traffic coming from the Docker network. https://laravel.com/docs/8.x/requests#configuring-trusted-proxies Try trusting `*`, and then narrow it down if that helps.
cn flag
i want to configure this on nginx, as i am making a service, where people can upload their own laravel apps, and i dont want to make them add or change their source code
vn flag
The Laravel app is where the URL generation occurs, and Laravel has a built-in and documented way of handling proxies like nginx, Docker, load balancers, etc. That's where the solution lies.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.