I am experimenting with containing website using Docker, and I managed to get half of it work. Website works correctly with Nginx with this config:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend_server/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
upstream backend_server {
server 127.0.0.1:8000;
}
But when I try to add php snippet
location ~ .php$ {
proxy_pass http://localhost:8081;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
it does not work, cannot find any .php file.
I tried with
proxy_pass http://backend_server/;
proxy_pass http://localhost:8000$uri;
But it does not matter.
New contributor
anonimason is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.