Nginx 1.0.3 — how to set ONLY for the return of statics?

Can't configure Nginx 1.0.3 — is to hook it up, immediately ignored .htaccess files, and other signs that he handles. php files, not giving them Apache.

Config taken from a working 0.8 with other VPS, everything is working as it should. Config was created automatically by the panel ISPManager — I only throw out the excess hosts, changed the path to the log and changed the IP.

CentOS 5.4, installed Nginx from CentALT.

Here is the config:

user nginx;
worker_processes 2;
worker_rlimit_nofile 100000;

error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

pid /var/run/nginx.pid;


events {
 worker_connections 1024;
 use epoll;
}


http {
 include /etc/nginx/mime.types;
 default_type application/octet-stream;

 "log_format" main '$remote_addr - $remote_user [$time_local] "$request" '
 '$status $body_bytes_sent "$http_referer" '
 '"$http_user_agent" "$http_x_forwarded_for"';

 access_log /var/log/nginx/access.log main;

 sendfile on;
 tcp_nopush on;
 tcp_nodelay on;
 server_tokens off;
 gzip on;
 gzip_static on;
 gzip_comp_level 5;
 gzip_min_length 1024;
 keepalive_timeout 65;
 "limit_zone" myzone $binary_remote_addr 10m;

 # Load config files from the /etc/nginx/conf.d directory
 include /etc/nginx/conf.d/*.conf;



 # another virtual host using mix of IP-, name-, and port-based configuration
#
 #server {
 # listen 8000;
 # listen somename:8080;
 # server_name somename alias another.alias;

 # location / {
 # root html;
 # index index.html index.htm;
 # }
#}


 # HTTPS server
#
 #server {
 # listen 443;
 # server_name localhost;

 # ssl on;
 # ssl_certificate cert.pem;
 # ssl_certificate_key cert.key;

 # ssl_session_timeout 5m;

 # ssl_protocols SSLv2 SSLv3 TLSv1;
 # ssl_ciphers directives ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
 # ssl_prefer_server_ciphers on;

 # location / {
 # root html;
 # index index.html index.htm;
 # }
#}

 client_max_body_size 16m;
 "log_format" isp '$bytes_sent $request_length';

 server {
 listen 50.57.78.248:80;
 server_name dogstudio.su dog-studio.org *.dog-studio.org *.dogstudio.su www.dog-studio.org www.dogstudio.su;
 rewrite ^(/manager/.*)$ https://$host$1 permanent;
 rewrite ^(/manager/.*)$ https://$host$1 permanent;
 error_page 404 = @fallback;
 location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
 proxy_pass http://50.57.78.248:8080;
 "proxy_redirect" http://dogstudio.su:8080/ /;
 proxy_set_header Host $Host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Real-IP $remote_addr;
}
 location / {
 proxy_pass http://50.57.78.248:8080;
 "proxy_redirect" http://dogstudio.su:8080/ /;
 proxy_set_header Host $Host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Real-IP $remote_addr;
}
 location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar)$ {
 set $proot "/home/dogstudio/public_html/dogstudio.su/public";
 if ( $host = "dog-studio.org" ) {
break;
}
 if ( $host = "dogstudio.su" ) {
break;
}
 if ( $host = "www.dog-studio.org" ) {
break;
}
 if ( $host = "www.dogstudio.su" ) {
break;
}
 if ( $host ~* ^((.*).dog-studio.org)$ ) {
 set $proot /home/dogstudio/public_html/$1/public;
break;
}
 if ( $host ~* ^((.*).dogstudio.su)$ ) {
 set $proot /home/dogstudio/public_html/$1/public;
break;
}
 access_log /home/dogstudio/public_html/dogstudio.su/log/access.nginx.log;
 root $proot;
}
 location @fallback {
 proxy_pass http://50.57.78.248:8080;
 proxy_set_header Host $Host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Real-IP $remote_addr;
}
}
}


What is wrong?

There is a site on HostCMS (dogstudio.su) if prescribed to Apache on port 80 and nginx turned off — displays normal; if prescribed Apache 8080, and run nginx — CMS throws an error "Not found license key". The same site with the same config on another VPS (dog-studio.org) — works as it should with the included nginx.
October 10th 19 at 07:39
2 answers
October 10th 19 at 07:41
nginx does not use files .htaccess. Only your own configs.

It is possible more in detail about "and other grounds it appears that he handles. php files, not giving them Apache"do
That is the problem. I need to make it work only for the return of statics and the rest were given to Apache. About other features — I wrote in the question, CMS is not working correctly. On another server with nginx 0.8 with the same config does not have this problem. Rummaged in search — it looks like it's not that nginx handles php files; and that it cuts some http headers... - Curtis_Windler commented on October 10th 19 at 07:44
He did not organize the scheme of apache+nginx, so I can't suggest where the trouble is.

But, if CMS gives an error — so php works. We have to make CMS more specific about the error and watch the error_log php - nikita.Stracke commented on October 10th 19 at 07:47
October 10th 19 at 07:43
Error it looks like cms for nginx is not able to process php. I have nginx and configured it so it gives off only static, php and Apache chews.

In General, I suggest to run Apache on localhost'e and change:
location / {
 proxy_pass http://50.57.78.248:8080;
 "proxy_redirect" http://dogstudio.su:8080/ /;


on

location / {
 proxy_pass http://127.0.0.1/;
 "proxy_redirect" off;

Not a bug in the headers that nginx gives... it has turned out. The whole array $_SERVER is given a distorted, everywhere populated with the IP of the visitor. Left to figure out why... maybe it's the settings mod_rpaf even, and not with nginx? - Curtis_Windler commented on October 10th 19 at 07:46
maybe a nginx config looks normal. - nikita.Stracke commented on October 10th 19 at 07:49
Sure, it was mod_rpaf!
In the config it does not need line RPAFsethostname On

The correct config mod_rpaf:
RPAFenable On
RPAFproxy_ips here.SP.server

That's all fixed!

Special thanks dirtyHabrBobrthat in PM helped to pick open the cause of the problem. - Curtis_Windler commented on October 10th 19 at 07:52
I note that there are in .htaccess use the IPS they are not listed correctly, or rather hgfa their dimensions after processing these files, and not before. treated mod real ip2 - Myrl.Swaniawski commented on October 10th 19 at 07:55

Find more questions by tags FrontendNginx