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
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