Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

729
Views
Nginx server config for codeigniter in docker, multiple applications

I have index.php and manager.php for those 2 applications in root, setup though docker with nginx, phpfpm and some other dependencies.

This is my docker-compose file, I put only the important parts.

services:
  web:
    container_name: web
    build:
      context: ./
      dockerfile: docker/nginx/Dockerfile
    volumes:
      - ./:/var/www
    ports:
      - 80
    depends_on:
      - app
    environment:
      VIRTUAL_HOST: ${VIRTUAL_HOSTS}
      VIRTUAL_PORT: 80
    networks:
      - nginx-proxy
      - my-app

  app:
    container_name: app
    build:
      context: ./
      dockerfile: docker/php/Dockerfile
    volumes:
      - ./:/var/www
    depends_on:
      - mysql
    ports:
      - 9000
    networks:
      - my-app
...

And this is my vhost file, i tried everything i knew or found on the internet to make it work without success, this is final form, of course still not working.

server {
    listen 80;
    server_name myapplication.local;

    index index.php index.html;

    root /var/www;

    location / {
        try_files $uri $uri/ =404;
    }

    location /manager.php {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index manager.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ \.php$ {
        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;
    }

    try_files $uri $uri/ /index.php;

    if (!-e $request_filename){
        rewrite ^/(.*)$ /index.php?/$1? last;
    }

    location ~ /\.ht {
        deny all;
    }

    location = /favicon.ico {
        log_not_found off; access_log off;
    }
    location = /robots.txt {
        log_not_found off; access_log off; allow all;
    }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }

    sendfile off;
}

If I access application normal works just fine, if I go to /manager.php or /manager.php/* I get 404, does any knows how I can configure nginx to work with this situation, thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I found the solution:

server {
    listen 80;
    server_name myapplication.local;

    index index.php index.html manager.php;

    root /var/www;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        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;
    }

    try_files $uri $uri/ /index.php /manager.php;

    if (!-e $request_filename){
        rewrite ^/manager.php/(.*)$ /manager.php?/$1? last;
        rewrite ^/(.*)$ /index.php?/$1? last;
    }

    location ~ /\.ht {
        deny all;
    }

    location = /favicon.ico {
        log_not_found off; access_log off;
    }
    location = /robots.txt {
        log_not_found off; access_log off; allow all;
    }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }

    sendfile off;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!