Помогите подобрать конфигурацию nginx+php5-fpm

Aleksandr

Пользователь
Уважаемые тех.админы,помогите пожалуйста разобраться в конфигурации виртуального хоста nginx. Проблема такая:Когда захожу с телефона на сайт,выскакивает ошибка(403 forbidden). Если захожу с компа,то норм.
Код:
    server {

      server_name www.мой домен;
      rewrite ^(.*) http://мой домен$1 permanent;
    }

    server {
        #listen       80 default sndbuf=32k rcvbuf=8k accept_filter=httpready;
        #listen  [::]:80 default sndbuf=32k rcvbuf=8k accept_filter=httpready;

        listen       80 default sndbuf=32k rcvbuf=8k;
        server_name  мой домен;
       
        charset utf8;

        location / {
            root  /home/мой домен;
            index index.php;
        }
       
        location ~ \.php$ {
        root           /home/мой домен;
        error_log /var/log/мой домен_error.log;
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass    unix:/var/run/php5-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_script_name;


            include fastcgi_params;
        }
       
        # proxy buffers - no 502 errors!
        proxy_buffer_size               128k;
        proxy_buffers                   4 256k;
        proxy_busy_buffers_size         256k;
        # fastcgi buffers - no 502 errors!
        fastcgi_buffering               on;
        fastcgi_buffer_size             16k;
        fastcgi_buffers                 16 16k;
   
        if ($http_referer ~ ^(http://(.*)www.scan-web\.ru(.*)|http://(.*)webkontrol\.com(.*)|http://(.*)www.webkontrol\.co\.uk(.*)|http://(.*)dm.audiolock.net(.*)|http://(.*)audiolock.net(.*)|http://(.*)infopolice.net(.*)|http://(.*)storm.assa.pro(.*)|http://(.*)content-watch.ru(.*)|http://(.*)text.ru(.*)|http://(.*)policeweb.net(.*)|http://(.*)webkontrol.ru(.*)|http://(.*)ruprotect.com(.*))) {
            return 403;
        }
       
        if ($http_referer !~* ^($|http://|https://) ){
            return 403;
        }
   
        if ($host !~* ^([a-z0-9-]+[\.])?мой\.домен$) {
            return 444;
        }
       
        if ($request_uri ~ "^/index.(php|html?)") {
            rewrite ^ /$1 permanent;
        }
       
        # pass the PHP scripts to FastCGI server listening on /tmp/php.sock;
        #
        # Old XBTT config
#       location ^~ /bt/ {
#          access_log   off;
#           if ( $query_string ~ "^uk=([^&?]{10})[&?]+(.*)$" ) {
#              set $uk $1;
#              set $qs $2&ip=$remote_addr;
#           }
#           if ( $query_string ~ "^uk=([^&?]{10})[&?]+((.*&|)ip=.*)$" ) {
#              set $uk $1;
#              set $qs $2;
#           }
#           if ( $qs ) {
#              rewrite ^.*/([a-z]+)(\.php|)$ /$uk/$1?$qs break;
#           }
#           rewrite ^/?(.*)$ /$1?ip=$remote_addr&$query_string break;
#           proxy_pass http://127.0.0.1:2710/;
#       }

        # Cached Images
        location ~* \.(jpg|jpeg|gif|png|css|js|swf|ico)$ {
            root         /home/мой домен;
            access_log   off;
            expires      30d;
            add_header   Cache-Control  public;
        }

        rewrite ^/index\.html$ /index.php;
       
        rewrite ^/category-(.*)-(.*).html /index.php?$2;
       
        rewrite ^/forum-(.*)-(.*).html /viewforum.php?$2;
   
        rewrite ^/topic-(.*)-(.*).html /viewtopic.php?$2;
       
        rewrite ^/profile-(.*)-(.*).html /profile.php?$2;

      


      location ~ \/(cache|log|attach_mod|cache|config|includes|language|triggers)\/ {
            deny all;
        }

        location ~ \.(.*sql|tpl|db|inc|log)$ {
            deny  all;
        }
      rewrite ^/sitemap/sitemap.xml$ /internal_data/sitemap/sitemap.xml last;
     # rewrite ^/internal_data/atom/(.*) /atom$1 last;
   
        # deny access to .htaccess, if apache's document root concurs with nginx's one
        location ~ /\.ht {
            deny all;
        }
       
        # deny access to critical files
        location ~ \.(.*sql|tpl|db|inc|log|md)$ {
            deny all;
        }
       
        location /1 {

   
            #auth_basic "Enter Password";
            #auth_basic_user_file /var/www/ivan/htpasswd;

               root /usr/share/;
               index index.php index.html index.htm;
               location ~^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                        fastcgi_pass    unix:/var/run/php5-fpm.sock; # 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $request_filename;
                       include /etc/nginx/fastcgi_params;
               }
               location ~*^/1/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /1 {
               rewrite ^/* /1 last;
        }


    }
 

JDVU

Пользователь
зачем все пихать в дефолтный конфиг? создали бы отдельно файл для вашего виртуального хоста и туда настройки
в вашем виде ничего не понять
 

JDVU

Пользователь
лан, вот мой как пример
server {
server_name

Please Login or Register to view hidden text.


rewrite ^(.*)

Please Login or Register to view hidden text.

permanent;
}

server {
listen 80 default sndbuf=32k rcvbuf=8k;
server_name my.site bt.my.site;
server_name_in_redirect off;

root /var/www/my.site/;

access_log /var/log/nginx/my.site.access.log;
error_log /var/log/nginx/my.site.error.log;

proxy_send_timeout 600;
proxy_read_timeout 600;

location / {
index index.php index.html;

if (!-f $request_filename){
set $rule_1 1$rule_1;
}

if (!-d $request_filename){
set $rule_1 2$rule_1;
}

rewrite ^/rss.xml /rss.php;
}

location ~ \.php$ {
include fastcgi_params;
try_files $fastcgi_script_name =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\.ht {
deny all;
}

location ~ \.(.*sql|tpl|db|inc|log|md)$ {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
root /var/www/my.site;
access_log off;
expires 1h;
add_header Cache-Control no-cache;
}

# sitemap rewrite
rewrite ^/sitemap.xml$ /internal_data/sitemap/sitemap.xml;

# Deny folder (Sec. lvl1)
location ~ \/(install|library)\/ {
deny all;
}
}

без проблем работает
 

Aleksandr

Пользователь
JDVU как правильно закрыть доступ по ip? Я знаю только такой способ
Код:
        if ($host !~* ^([a-z0-9-]+[\.])?мой\.домен$) {
            return 444;
        }
 
Сверху