Welcome! Log In Create A New Profile

Advanced

Nginx + Apache

Posted by cesar 
Nginx + Apache
August 06, 2010 01:25PM
Hello.

I am using nginx to serve statc content and apache to serve dynamic content on cpanel server.

But i am having problem with some domains using joomla(with rewrite) and others.

My question is, how to disable nginx in one domain? Example, to ignore a domain and send directly to apache?

example of my virtual hosts:

[code]
server {
access_log off;

error_log logs/vhost-error_log warn;
listen 80;
server_name domain.com www.domain.com;

location ~* \.(gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|htm|html|txt|js|css|exe|zip|rar|gz|tgz|uha|7z|doc|docx|xls|xlsx|pdf)$ {
root /home/user/public_html;
access_log /usr/local/apache/domlogs/domain.com-bytes_log bytes_log;
access_log /usr/local/apache/domlogs/domain.com combined;
expires 7d;
}

location ~* \.(ftpquota|htaccess)$ {
deny all;
}

location / {
client_max_body_size 100m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;

proxy_redirect http://www.domain.com:81 http://www.domain.com;
proxy_redirect http://domain.com:81 http://domain.com;

proxy_pass http://000.000.000.000:81/;

proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
}
[/code]
Re: Nginx + Apache
August 06, 2010 09:04PM
I have a similar setup and I just let apache handle all the mod rewrites & php files. Here is what I use to make that happen - it works great.

[code]
server {
listen 123.45.67.89:80;

server_name example.com;

root /www-data/example.com/httpdocs;
index index.php;

access_log off;
error_log /var/log/nginx/example_error.log;

try_files $uri $uri/ @backend;

rewrite ^/(.*)/favicon.ico$ /favicon.ico last;

# Pass off php requests to Apache
location ~ \.php {
include /usr/local/etc/nginx/proxypass.conf;
proxy_pass http://127.0.0.1:81;
}

location @backend {
include /usr/local/etc/nginx/proxypass.conf;
proxy_pass http://127.0.0.1:81;
}

# Serve static files directly (let nginx handle all these files below)
location ~* ^.+\.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js)$ {
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires 7d;
}
}
[/code]



Edited 2 time(s). Last edit at 08/06/2010 09:07PM by Mayhem30.
Re: Nginx + Apache
August 07, 2010 02:12AM
You can post the content of file /usr/local/etc/nginx/proxypass.conf also?
Re: Nginx + Apache
August 07, 2010 02:13PM
Sure, no problem.

[code]
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 16k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
[/code]
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 290
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready