-
-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG] nginx return file not found with nginx-proxy #262
Comments
Hello @cod3rshotout! This is not a bug in the nginx-proxy-automation... but more a config in your set up. How is your php-fpm running? Can you share your Dockerfile and entrypoint script? You must check the settings on the fpm to respond, the proxy seems to be doing it's job. There is a similar issue on this: I might take a took by tomorrow on that as well ok? Meanwhile, If you find the solution, please post it here for future reference. Thanks! |
Hi @evertramos thanks for your quick reply, I've been trying to fix this issue for days without any luck.
the
essentially I have three services:
The
when I start the container using
and when I inspect the log of your image:
Thanks in advance for any help. Kind regards |
Hi @evertramos another test that I did is update the nginx template with this: Now the "File not found" error is gone, but all the static files such js, CSS and images aren't loaded, infact I get 404. Could you help me please? |
Hello @cod3rshotout! Today I got some time and took me a couple hours to figure it out, but here it is, follow the steps: 1. Create a simple docker compose file as of (docker-compose.yml):version: "3.9"
services:
php-fpm:
image: php:fpm-alpine3.13
container_name: php-fpm
volumes:
- ./../data/site:/var/www/html
environment:
- VIRTUAL_HOST=[your url]
- LETSENCRYPT_HOST=[your url]
- VIRTUAL_PROTO=fastcgi
networks:
default:
external:
name: proxy
This is my index.php which was in volume above: <?php
echo "PHP FPM over nginx-proxy!"; 2. Add special settings to nginx-proxy to your URLAs of quoted in the nginx proxy, we can have special setting per host as following instruction below: Find the ./vhost.d which was binded in the proxy. You can find the right path at NGINX_FILES_PATH variable at .env file. The files below must be added to the right place which is ./vhost.d folder. So, here are the files: file 1 under the name: [your url]_location try_files $uri $uri/ /index.php?$args; file 2 under the name: [your url] root /var/www/html;
index index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass [your url];
fastcgi_index index.php;
}
3. Fire up your docker-compose (php-fpm) and be happy! 😃
|
Hi @evertramos many thanks for your precious help! You've helped me a lot! The file not found problem seems resolved, even with the original I just have few questions:
mysite.com, which contains this:
and mysite.com_location, which contains this:
inside the app which runs over php-fpm I have this docker-compose.yml content:
when I do
Thanks again for your precious help! Kind regards |
@cod3rshotout are you using Laravel? If so, open a new discussion on that I will help you out there... and I will delete this last post and lock the issue. ok? Wait on you. |
@evertramos I'm using CodeIgniter 4 with this app starter: https://github.com/agungsugiarto/boilerplate I'have sended on this email [...] my app, may could you have a look? Thanks again |
In order to serve the static files from a container using the nginx proxy, the nginx proxy must have access to files statically... it would not 'proxy' but 'read' and serve the files... which means you must mount the app files into the proxy... PLEASE DON'T GO THAT WAY! I would recommend you put up a new, light and clean nginx begind the nginx proxy along with your php-fpm service so you can have full management of your routes/locations, Here is a very simple example: https://github.com/evertramos/nginx-behind-proxy Hope it helps! |
Thanks for the tips of @evertramos I was able to make it working. First of all I have created a
then, inside my app directory I have created the nginx configurations structure:
where I have
then I have
and
the site load now but there are some issues:
|
I'm using this image to run multiple sites/app on a single nginx instance. So far, I was able to run a static site and a nodejs application without problems but I'm facing an issue with a php application created with codeigniter.
Essentially the project structure looks like this:
Inside the
php-application/docker-compose.yml
I have this:The php application runs over
php-fpm
specifically on the port9000
usingfastcgi
, for this I used the following directives:to make it working, I also specified the
VIRTUAL_ROOT
that should redirect all the request on the index.php which is available in this directory/var/www/html/public
. Project structure:the problem's that when I start the
php-application
container usingdocker-compose up --build -d
, I get this when I visitmysite.com
(hide for privacy the real domain):Inspecting the
nginx
log usingsudo docker logs -f nginx
I get:what I did wrong?
UPDATE:
output of /var/log/nginx/error.lg
UPDATE 2
The text was updated successfully, but these errors were encountered: