Score:0

HAProxy downloads PHP files instead of displaying in browser

ru flag

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
djdomi avatar
za flag
fastcgi listen usually on 127.0.0.1 and not on 0.0.0.0
JeremyCanfield avatar
ru flag
Same issue with 127.0.0.1
djdomi avatar
za flag
lsof - Pi :9000
Score:0
ru flag

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

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.