Please help me with my nginx.conf file.
For now only root page ("/") is working, all others give me "The page isn't redirecting properly".
I have already tryed >10 config samples and didn't have a success.
I removed .htaccess from the root of my drupal folder.
I'd love to see the answers of people who really understand nginx.conf, but not only two strings from some tutorial - I've done this stuff a lot already.
Thanks!
Here's my conf:
user www www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include 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;
reset_timedout_connection on;
sendfile on;
aio sendfile;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
upstream backend {
server 77.72.19.19:81;
}
server {
listen 77.72.19.19:80 default accept_filter=httpready;
server_name psyhonetika.org;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
gzip on;
gzip_static on;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
set $myroot /usr/local/www/apache22/data/alfa;
root $myroot;
location ~ ^\. {
deny all;
}
location ~
\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$
{
deny all;
}
set $boost "";
set $boost_query "_";
if ( $request_method = GET ) {
set $boost G;
}
if ($http_cookie !~ "DRUPAL_UID") {
set $boost "${boost}D";
}
if ($query_string = "") {
set $boost "${boost}Q";
}
if ( -f $myroot/cache/normal/$http_host$request_uri$boost_query$query_string.html )
{
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$
/cache/normal/$http_host/$request_uri$boost_query$query_string.html break;
}
if ( -f $myroot/cache/perm/$http_host$request_uri$boost_query$query_string.css ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.css
break;
}
if ( -f $myroot/cache/perm/$http_host$request_uri$boost_query$query_string.js ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.js
break;
}
location ~*
\.(txt|jpg|jpeg|css|js|gif|png|bmp|flv|pdf|ps|doc|mp3|wmv|wma|wav|ogg|mpg|mpeg|mpg4|htm|zip|bz2|rar|xls|docx|avi|djvu|mp4|rtf|ico)$
{
root $myroot;
expires max;
add_header Vary Accept-Encoding;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass "http://backend";
break;
}
}
location ~* \.(html(.gz)?|xml)$ {
add_header Cache-Control no-cache,no-store,must-validate;
root $myroot;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass "http://backend";
break;
}
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
location / {
proxy_pass http://backend;
}
}
}
UPD:
If I replace
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
with:
try_files $uri $uri/ @drupal;
location @drupal {
rewrite ^ /index.php?q=$uri last; # for Drupal 6
}
Then all non-root pages give me 404 "The requested URL was not found on this server".