Nginx php-fpm on Docker desktop issue

I have nginx and php-fpm running in a single container on Docker desktop for Windows. I am IT and not a developer so please dumb it down for me. I have been trying to get a configuration to work without success. I need to be able to allow multiple subdomains to pass through to php-fpm where the php app will determine which database to open by specific sub domain. so clientA.mydomain.com clientB.mydomain.com should all just pass through to php, and the app will know which DB to connect to.

I have searched and found solutions to redirect subdomains to separate sites, but I need to allow all subdomains to single site and process like localhost does.

This work fine using localhost or 127.0.0.1 but when I try to use a dns url the site stops logging in and all ajax calls stop working. Seems like the session variables stop getting passed back. The login page shows, and a failed password will show that error so I know the site is communicating with the proper DB but the log does not show any errors or ajax responses.

server {
    listen       80  default_server;
    server_name  _;  
    # I have tried server_name *.mydomain.com and server_name .mydomain.com, the latter yeilds the same results as this current config.
    
    root /usr/share/nginx/html;
    server_tokens off;

    index index.php index.html index.htm;

    charset utf-8;
    # Add stdout logging
    error_log /dev/stdout info;
    access_log /dev/stdout;

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

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

I had to remove a lot to submit the question.

Using localhost or 127.0.01 with this same config, login works, ajax is responding, and site loads main page as expected.

nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "POST /login.php HTTP/1.1" 302
nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET / HTTP/1.1" 200 
nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET /framework.js?version=
nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET /resources/all.css 
192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET /resources/js/pdfjs/pdf.js 
nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET /app.js?version=2021
nginx stdout | 192.168.80.1 - - [08/Sep/2021:13:23:00 +0000] "GET /resources/images/login_loader_logo.gif
192.168.80.1 - - [08/Sep/2021:13:23:01 +0000] "GET /ajax.php?_dc=163110738
192.168.80.1 - - [08/Sep/2021:13:23:02 +0000] "POST /ajax.php HTTP/1.1" 200 
192.168.80.1 - - [08/Sep/2021:13:23:02 +0000] "GET /ajax.php?_dc=1631107382410&

When using the url entry I created in my host file to test it seems like js and ajax are not working using URL.

192.168.96.1 - - [08/Sep/2021:13:29:45 +0000] "GET /login.php HTTP/1.1" 200
192.168.96.1 - - [08/Sep/2021:13:29:45 +0000] "GET /showClientLogo.php HTTP/1.1" 200
192.168.96.1 - - [08/Sep/2021:13:29:46 +0000] "GET / HTTP/1.1" 302
192.168.96.1 - - [08/Sep/2021:13:29:46 +0000] "GET /login.php HTTP/1.1" 200
192.168.96.1 - - [08/Sep/2021:13:29:47 +0000] "GET /showClientLogo.php HTTP/1.1" 200
192.168.96.1 - - [08/Sep/2021:13:29:57 +0000] "POST /login.php HTTP/1.1" 302
192.168.96.1 - - [08/Sep/2021:13:29:57 +0000] "GET / HTTP/1.1" 302
192.168.96.1 - - [08/Sep/2021:13:29:57 +0000] "GET /login.php HTTP/1.1" 200
192.168.96.1 - - [08/Sep/2021:13:29:58 +0000] "GET /showClientLogo.php HTTP/1.1" 200

Thanks in advance.


Solution 1:

@MichaelHampton was correct, I tried several things, noticed that new sessions were getting created during redirects which caused the system to keep landing on the login page. There is an internal setting in the app which deals with cross domain cookies and when I turned that off the site works using a domain url. Since I am in testing I am only using http and not https.