5 months ago

Docker instance's nginx config doesn't seem to match route

Posted 5 months ago by mkrell

Hello. I have an nginx config that works perfectly fine when my site is deployed, but does not work in my docker container I use for local dev.

The site is deployed without docker on Forge, and works fine. The docker container's nginx, however, does not seem to match a particular location block.

We have three location blocks for the site, one for Laravel, one for an old PHP app that's integrated with the site, and one that is supposed to match three Code Ignitor routes. The CI routes are the ones not working in Docker.

Here is my nginx config:

server {
    listen 80 default_server;

    root /var/www/html/public;

    index index.html index.htm index.php;

    server_name _;

    charset utf-8;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }
    client_max_body_size 100M;

    # Code Ignitor - Not working
    location ~ /old/(statement|invoice|crosscheck)(/.*)? {
        try_files /old/index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php5.6-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/index.php;
        fastcgi_param SCRIPT_NAME /index.php;
        include fastcgi_params;

        # long for xdebug session
        fastcgi_read_timeout 3600;

# Old PHP app - Works
    location ~ /old/.*\.php {
        try_files $uri /index.php?$query_string;

        # long for xdebug session
        fastcgi_read_timeout 3600;

# Laravel - Works
    location / {
        try_files $uri $uri/ /index.php$is_args$args;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php5.6-fpm.sock;

        # long for xdebug session
        fastcgi_read_timeout 3600;

    error_page 404 /index.php;

    location ~ /\.ht {
        deny all;

When I try going to the CI routes on docker (say, /old/crosscheck), the app goes to my catch-all route in laravel. It never hits the /old/index.php like it's supposed to.

The Nginx config is the same on Forge and in Docker (except for the paths to PHP and such).

I've tried changing the regex on that block to /old/crosscheck to see if it would match, no dice.

I've looked at the access log and the error log, nothing helpful.

Any idea what's going on?

Thx, Matt

Please sign in or create an account to participate in this conversation.