Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

726
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda