Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

733
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda