2013-04-11 48 views
0

我有我的phpMyAdmin設置如下。這在站點的默認服務器塊(可用和啓用站點)內。NGINX更改位置塊內的phpMyAdmin端口

如何在位置塊或某個位置將端口更改爲8003而不影響端口80的功能?

server{ 
    listen 80; ## listen for ipv4 
    listen [::]:80 default ipv6only=on; ## listen for ipv6 

    [..........] 

    location /phpmyadmin { 
     root /usr/share/; 
     index index.php index.html index.htm; 
     location ~ ^/phpmyadmin/(.+\.php)$ { 
      try_files $uri =404; 
      root /usr/share/; 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include /etc/nginx/fastcgi_params; 
     } 
     location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { 
      root /usr/share/; 
     } 
    } 
     location /phpMyAdmin { 
      rewrite ^/* /phpmyadmin last; 
     } 

    [..........] 

} 

回答

1

您不能在位置塊中設置端口。這是沒有意義的,因爲當處理位置時客戶端已經連接。您可以創建一個新的服務器塊,然後監聽您想要的端口,並將相應的位置塊置於新的服務器塊中。

+0

該死的,希望這是可能的....一個更好的方式來確保phpmyadmin? – Anup

+1

在不同的端口上收聽不會比改變URL更安全,如果你願意,你可以這樣做。否則,您可以爲該位置激活HTTP認證:http://wiki.nginx.org/HttpAuthBasicModule –