Nginx htaccess 用于 redmine 中的查询字符串

Nginx htaccess 用于 redmine 中的查询字符串

这是一个来自
nginx htaccess 在 redmine 中对特殊页面不起作用

我再说一遍:我有 redmine 项目管理系统。此外,我还有 nginx,就像 redmine 的反向代理一样。因此,我需要为用户屏蔽 redmine 中的某些页面。在 redmine.conf 中,我执行了以下操作:

location /projects/wwe/dmsf
{
        auth_basic "Test4";
        auth_basic_user_file /etc/nginx/legalinfopass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
}

我通过 htpasswd 生成了 htaccess 文件。它起作用了。但我需要阻止QUERY STRING。我想要类似的东西

location /projects/wwe/dmsf?folder_id=351
{
        auth_basic "Test4";
        auth_basic_user_file /etc/nginx/legalinfopass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
}

但它当然不起作用。我的完整内容redmine.conf

upstream redmine_default
{
    #server localhost:3000;
    server unix:/tmp/redmine.socket;
}

server
{
    include listen.conf;
    include listen_ssl.conf;

        ssl_certificate_key /etc/letsencrypt/live/redmine.wwe.com/privkey.pem;
        ssl_certificate /etc/letsencrypt/live/redmine.wwe.com/fullchain.pem;

        server_name www.redmine.wwe.com redmine.wwe.com;

# letsencrypt
        location ~ ^/\.well-known/acme-challenge
        {
                auth_basic off; root /home/www/acme;
        }

    location /
    {
        rewrite ^ https://redmine.wwe.org$request_uri? permanent;
    }
}

server
{
    listen 192.168.110.24;
    server_name redmine.wwe.org www.redmine.wwe.org;

    # letsencrypt
    location ~ ^/\.well-known/acme-challenge
    {
        auth_basic off;
        root /home/www/acme;
    }

    location /
    {
        rewrite ^ https://redmine.wwe.org$request_uri? permanent;
    }
}

server
{
    listen 192.168.110.24:443 ssl http2;

    client_max_body_size 250M;

    server_name redmine.wwe.org;

    ssl_certificate_key /etc/letsencrypt/live/www.redmine.wwe.org/privkey.pem;
    ssl_certificate /etc/letsencrypt/live/www.redmine.wwe.org/fullchain.pem;


# letsencrypt
    location ~ ^/\.well-known/acme-challenge
    {
        auth_basic off; root /home/www/acme;
    }

    location /projects/wwe/wiki/PHP_programmers
    {
        auth_basic "Test";
        auth_basic_user_file /etc/nginx/wikipass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
    }

    location /projects/wwe/wiki/Vacancy_interviews
    {
        auth_basic "Test";
        auth_basic_user_file /etc/nginx/wikipass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
    }

    location /projects/wwe/wiki/Hidden_for_creds
    {
        auth_basic "Test2";
        auth_basic_user_file /etc/nginx/credpass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
    }

    location /projects/wwe/wiki/Management
    {
        auth_basic "Test3";
        auth_basic_user_file /etc/nginx/managementpass;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
    }

    location /projects/wwe/dmsf?folder_id=351
    {
                auth_basic "Test4";
                auth_basic_user_file /etc/nginx/legalinfopass;
                alias /usr/share/redmine/public;
                try_files $uri @fcgi;
    }

    location /files
    {
        auth_basic off;
        internal;
        root /usr/share/redmine;
    }

    location /public
    {
        auth_basic off;
        internal;
        root /usr/share/redmine;
    }

    location /tmp2
    {
        auth_basic off;
        internal;
        root /usr/share/redmine;
    }


    location /
    {
        auth_basic off;
        alias /usr/share/redmine/public;
        try_files $uri @fcgi;
    }

    location @fcgi
    {
        auth_basic off;

        ##proxy_set_header X-Sendfile-Type X-Accel-Redirect;
        ##proxy_set_header X-Accel-Mapping /usr/share/redmine/=/;

        ##proxy_pass http://redmine2_default;
        include uwsgi_params;
        uwsgi_pass redmine_default;
        uwsgi_modifier1 7;
    }
}

答案1

您应该尝试一下,并尝试使用正则表达式来根据您的要求进行调整。

location ~* ^\/projects/wwe/dmsf.+351
{
    auth_basic "Test4";
    auth_basic_user_file /etc/nginx/legalinfopass;
    alias /usr/share/redmine/public;
    try_files $uri @fcgi;
}

相关内容