2013-11-28 7 views
7

मैं अपने phpmyadmin निर्देशिका को केवल मेरे आईपी द्वारा घर से अनुमति देने की कोशिश कर रहा हूं। यह मुझे एक 404 त्रुटि देता है जब मैं पृष्ठ पर जाने केnginx निर्देशिका आईपी प्रतिबंध काम नहीं कर रहा है

location ^~ /9ZXyNSDVTM7yExN/ { #this is the phpmyadmin directory (I renamed it) 
     allow 127.10.176.5;  #This is my IP 
     deny all; 
} 

मेरे समस्या है, यह एक दूरस्थ VPS मेरी नेटवर्क पर नहीं है। अजीब बात यह है कि, यदि मैं उपरोक्त कोड में आईपी को एक यादृच्छिक आईपी में बदलता हूं जो मेरा नहीं है, तो यह 404 त्रुटि के बजाय 403 निषिद्ध त्रुटि देता है।

यदि मैं इस पूरे स्थान ब्लॉक को हटाता हूं तो मुझे 404 त्रुटि नहीं मिलती है। यह प्रतिबंध ब्लॉक क्यों काम नहीं कर रहा है?

इसके अलावा, यहाँ मेरा पूरा nginx.conf है:

#user html; 
worker_processes 1; 

#error_log logs/error.log; 
#error_log logs/error.log notice; 
#error_log logs/error.log info; 

#pid  logs/nginx.pid; 


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 logs/access.log main; 

    sendfile  on; 
    #tcp_nopush  on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 

    #gzip on; 

    server { 
     listen  80; 
     server_name localhost; 

     #charset koi8-r; 

     #access_log logs/host.access.log main; 

     location/{ 
      root /srv/http; 
      index index.php; 
#  try_files $uri.html $uri/ =404; 
     } 

     #error_page 404    /404.html; 

     # redirect server error pages to the static page /50x.html 
     # 
     error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
      root /usr/share/nginx/html; 
     } 

     # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
     # 
     #location ~ \.php$ { 
     # proxy_pass http://127.0.0.1; 
     #} 

     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
     # 
     #location ~ \.php$ { 
     # root   html; 
     # fastcgi_pass 127.0.0.1:9000; 
     # fastcgi_index index.php; 
     # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
     # include  fastcgi_params; 
     #} 

     # deny access to .htaccess files, if Apache's document root 
     # concurs with nginx's one 
     # 
     #location ~ /\.ht { 
     # deny all; 
     #} 
    location ^~ /9ZXyNSDVTM7yExN/ { 
     allow 127.10.176.5; 
     deny all; 
    } 



     location ~ \.php$ { 
     fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
     fastcgi_index index.php; 
     root /srv/http; 
     include fastcgi.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 HIGH:!aNULL:!MD5; 
    # ssl_prefer_server_ciphers on; 

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

यहां एक नज़र डालें http://wiki.nginx.org/Pitfalls – foibs

उत्तर

0

समस्या यह है कि आप एक "रूट" स्थान ब्लॉक के भीतर घोषित नहीं है। बस उसी रूट को "/" के रूप में घोषित करें और इसे

2

root और indexlocation ^~ /9ZXyNSDVTM7yExN/ पर कार्य करना चाहिए। अनुमतियों को अस्वीकार/अस्वीकार करें, यह सिर्फ यह नहीं जानता कि क्या दिखाना है।

और मिलान क्रम से सावधान रहें। जांचें कि /9ZXyNSDVTM7yExN/index.php का अनुरोध करने वाले किसी भी मौके से \.php$ स्थान पर नहीं आते हैं, जिसमें अनुमति/अस्वीकार नहीं है।

उम्मीद है कि यह मदद करता है।

संबंधित मुद्दे