We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40249
    • 31 Posts


    I'd like to protect the root with passwd and make the urlfriendly rewrite for modx. only the rewriting works but the password won't be requested.

    my ispconfig nginx directives looks like this

    location / {
        index index.html index.php
        auth_basic "Protected Area";
        auth_basic_user_file /var/www/clients/client21/web22/web/htpasswd;
        client_max_body_size 0;
        if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php?q=$1 last;
        }
    }
    
    location ~ /\.ht {
        deny  all;
    }
    
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  unix:/var/run/php5-fpm.sock;
        fastcgi_read_timeout 600; 
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        client_max_body_size 0;
    }


    seems like the auth_basic won't be executed or overwriten by the rewrite rule. anyone got a idea?

    This question has been answered by degoya. See the first response.

    • discuss.answer
      • 40249
      • 31 Posts
      after my post got so may views and no reply i post the solution here if someone else is looking for it.

      location / {
          index index.html index.php
          client_max_body_size 0;
          if (!-e $request_filename) {
                  rewrite ^/(.*)$ /index.php?q=$1 last;
          }
      }
       
      location ~ /\.ht {
          deny  all;
      }
       
      location ~ \.php$ {
          auth_basic "Protected Area";
          auth_basic_user_file /var/www/clients/client21/web22/web/htpasswd;
          include /etc/nginx/fastcgi_params;
          fastcgi_pass  unix:/var/run/php5-fpm.sock;
          fastcgi_read_timeout 600;
          fastcgi_buffers 16 16k;
          fastcgi_buffer_size 32k;
          client_max_body_size 0;
      }