By WebshapedBiz
I’m trying to build an Ubuntu 18.04 based, Apache PHP-FPM web server with multiple virtual hosts, behind Nginx as a reverse proxy. Everything works fine up to the point where I configure Nginx to be the reverse proxy. Now I have this:
static HTML files are OK
php files are downloaded instead of executed
the worst thing is that when I try to fetch my info.php (which only has the basic HTML5 scaffold with title meta tag, to know which virtual host is served, and <?php phpinfo(); ?>) I’m being served with the different file, without a clue from where it was served.
When bypassing Nginx on port 8080 everything is back to normal and my PHP is working.
Here’s my /etc/nginx/sites-available/apache (my_server_ip is real IP):
server {
listen 80;
server_name foobar.net www.foobar.net test.io www.test.io;
location / {
proxy_pass http://my_server_ip:8080;
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;
}
}
I’ve lost two days so far, I found no similar issues on the web, and I’m desperate so any help would be greatly appreciated.
Cheers.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, @WebshapedBiz
May I ask if you use or have installed php-fpm as well? The thing is that you will need it in order to serve those requests.
Looking forward to your reply.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.