【问题标题】:NGINX change phpMyAdmin port within a location blockNGINX 更改位置块内的 phpMyAdmin 端口
【发布时间】:2013-04-04 07:22:07
【问题描述】:

我的phpMyAdmin 设置如下。这在 sites-available 和 sites-enabled 中的默认服务器块内。

如何在 location 块内或某处将端口更改为 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;
        }

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

}

【问题讨论】:

    标签: php linux apache nginx


    【解决方案1】:

    您不能在位置块中设置端口。这是没有意义的,因为在处理位置时客户端已经连接。不过,您可以创建一个新的服务器块,监听您想要的端口,并将有问题的位置块放入新的服务器块中。

    【讨论】:

    • 在不同的端口上侦听不会比更改 URL 更安全,如果您愿意,可以这样做。否则,您可以为该位置激活 HTTP 身份验证:wiki.nginx.org/HttpAuthBasicModule
    猜你喜欢
    • 1970-01-01
    • 2014-08-27
    • 2018-06-30
    • 2022-11-16
    • 1970-01-01
    • 2014-03-25
    • 2013-06-25
    • 2020-01-15
    • 1970-01-01
    相关资源
    最近更新 更多