Hello,
After days of trying I still can't get it work.
I want to set Nginx as reverse proxy in the front of Apache. Everything is working fine except PHP. Depending on the settings Nginx can't find the PHP files and sometimes it wants to download them instead of executing.
Any help is appreciated.
This is my config:
server {
listen *.*.*.*:80;
root /*/*/public_html;
index index.php;
location ~ \.php {
# this block will catch any requests with a .php extension
# normally in this block data would be passed to a FastCGI process
# these two lines tell Apache the actual IP of the client being forwarded
# Apache requires mod_proxy (http://bit.ly/mod_proxy) for these to work
# Most Apache 2.0+ servers have mod_proxy configured already
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $remote_addr;
# this next line adds the Host header so that apache knows which vHost to serve
# the $host variable is automatically set to the hostname Nginx is responding to
proxy_set_header Host $host;
# And now we pass back to apache
# if you're using a side-by-side configuration the IP can be changed to
# apache's bound IP at port 80 such as http://192.170.2.1:80
proxy_pass http://*.*.*.*:8080;
}
# if you don't like seeing all the errors for missing favicon.ico in root
location = /favicon.ico { access_log off; log_not_found off; }
# if you don't like seeing errors for a missing robots.txt in root
location = /robots.txt { access_log off; log_not_found off; }
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Thanx in advance!
After days of trying I still can't get it work.
I want to set Nginx as reverse proxy in the front of Apache. Everything is working fine except PHP. Depending on the settings Nginx can't find the PHP files and sometimes it wants to download them instead of executing.
Any help is appreciated.
This is my config:
server {
listen *.*.*.*:80;
root /*/*/public_html;
index index.php;
location ~ \.php {
# this block will catch any requests with a .php extension
# normally in this block data would be passed to a FastCGI process
# these two lines tell Apache the actual IP of the client being forwarded
# Apache requires mod_proxy (http://bit.ly/mod_proxy) for these to work
# Most Apache 2.0+ servers have mod_proxy configured already
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $remote_addr;
# this next line adds the Host header so that apache knows which vHost to serve
# the $host variable is automatically set to the hostname Nginx is responding to
proxy_set_header Host $host;
# And now we pass back to apache
# if you're using a side-by-side configuration the IP can be changed to
# apache's bound IP at port 80 such as http://192.170.2.1:80
proxy_pass http://*.*.*.*:8080;
}
# if you don't like seeing all the errors for missing favicon.ico in root
location = /favicon.ico { access_log off; log_not_found off; }
# if you don't like seeing errors for a missing robots.txt in root
location = /robots.txt { access_log off; log_not_found off; }
# this will prevent files like .htaccess .htpassword .secret etc from being served
# You can remove the log directives if you wish to
# log any attempts at a client trying to access a hidden file
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Thanx in advance!