0

I have nginx and php-fpm running on Docker. When using the hostname of my Docker system (docker1.freekb.net), the phpinfo.php page displays in the browser, thus I know that I have nginx and php-fpm properly configured to serve PHP pages. Here is the server block in /etc/nginx/conf.d/default.conf. Requests from nginx on port 80 are forwarded onto PHP on port 9000.

server { listen 80; server_name stage.freekb.net; root /var/www/stage; index index.html phpinfo.php; location / { try_files $uri $uri/ /index.html; } location ~ \.php$ { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 0.0.0.0:9000; fastcgi_index phpinfo.php; include fastcgi_params; } } 

I have HAProxy setup to forward requests onto nginx. Here is my listen block in /etc/haproxy/haproxy.cfg. When I go to http://haproxy.freekb.net/index.html, the nginx welcome page is displayed, thus I know that HAProxy is able to forward requests onto nginx.

However, when I go to http://haproxy.freekb.net/phpinfo.php, the phpinfo.php is downloaded to my local PC. I suspect this means there is something awry with fastcgi. I'm not sure what has to change in order for PHP pages to be displayed in the browser when using HAProxy.

listen nginx bind *:80 mode tcp balance roundrobin server nginx1 docker1.freekb.net:80 check 
3
  • fastcgi listen usually on 127.0.0.1 and not on 0.0.0.0 Commented Nov 21, 2021 at 21:03
  • Same issue with 127.0.0.1 Commented Nov 21, 2021 at 21:36
  • lsof - Pi :9000 Commented Nov 22, 2021 at 10:00

1 Answer 1

1

Just in case others find this article, I want to share what I discovered. I was not clearing my web browsers cache/history after making an nginx/php-fpm change. All I simply had to do was to clear my web browsers history and now I am able to display the phpinfo.php page in my

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.