Toon posts:

Beveiligen pagina in Nginx serverblock

Pagina: 1
Acties:

Vraag


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Hi,

Wil graag een extra laag van beveiliging aanbrengen op mijn wp-admin pagina met mijn Nginx webserver en diens config (ja ik weet dat ik de URL kan redirecten naar pieptjepuk/wp-admin of andere subdomains maar daar ben ik niet naar op zoek).

Dit werkt bij mij alleen niet geheel goed, heb hiervoor een hele tijd gedraaid met een block op IP-adres(sen), dit vond ik echter onhandig en heb toen maar besloten alles dicht te zetten:

code:
1
2
3
4
    location ~ ^/(wp-admin|wp-login.php) {
    allow xxx.xxx.xxx.xxx;
    deny all;
    }


Dacht ik dat het beveiligen met een PWD ook een optie zou zijn voor mijn websites, dit lukt alleen niet helemaal, het beveiligen an sich wel, echter het parsen/tonen van wp-admin niet (deze download login.php nu in plaats van het tonen).

Doe ik iets verkeerd?

code:
1
2
3
4
5
    location ~ ^/(wp-admin|wp-login.php) {
    auth_basic "Restricted Area: WordPress";
        auth_basic_user_file  /usr/local/etc/nginx/.htpasswd;

    }


Fora van Nginx en dergelijke al op nagelopen en wat tips/trucs gevonden, misschien dat iemand het hier weet of al eens tegenaan is gelopen? ;(

Beste antwoord (via Verwijderd op 06-09-2016 11:16)


  • Ventieldopje
  • Registratie: December 2005
  • Laatst online: 19:53

Ventieldopje

I'm not your pal, mate!

With this configuration, nginx will only match one of the two blocks - the one with the highest precedence.

The solution is to combine the PHP block into the AUTH block. This is the approach recommended by the nginx author himself, Igor Sysoev.
http://stackoverflow.com/a/11167338

:Y)

www.maartendeboer.net
1D X | 5Ds | Zeiss Milvus 25, 50, 85 f/1.4 | Zeiss Otus 55 f/1.4 | Canon 200 f/1.8 | Canon 200 f/2 | Canon 300 f/2.8

Alle reacties


Acties:
  • 0 Henk 'm!

  • 8088
  • Registratie: December 2000
  • Niet online

8088

NaN

Verwijderd schreef op maandag 05 september 2016 @ 14:11:
Fora van Nginx en dergelijke al op nagelopen en wat tips/trucs gevonden
Geen van deze oplossingen gevonden? Met je huidige config weet Nginx niet dat 'ie je script door moet geven aan de PHP process manager.

Do you seek to engage in or have you ever engaged in terrorist activities, espionage, sabotage, or genocide?


Acties:
  • Beste antwoord
  • 0 Henk 'm!

  • Ventieldopje
  • Registratie: December 2005
  • Laatst online: 19:53

Ventieldopje

I'm not your pal, mate!

With this configuration, nginx will only match one of the two blocks - the one with the highest precedence.

The solution is to combine the PHP block into the AUTH block. This is the approach recommended by the nginx author himself, Igor Sysoev.
http://stackoverflow.com/a/11167338

:Y)

www.maartendeboer.net
1D X | 5Ds | Zeiss Milvus 25, 50, 85 f/1.4 | Zeiss Otus 55 f/1.4 | Canon 200 f/1.8 | Canon 200 f/2 | Canon 300 f/2.8


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Had al met de precedence geknoeid. Zo nogmaals proberen.

Thanks heren

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Heb nu PHP block in AUTH block gezet en gaat nu goed:

code:
1
2
3
4
5
6
7
8
9
10
    location ~ ^/(wp-admin|wp-login.php) {
    auth_basic "Restricted Area: WordPress";
        auth_basic_user_file  /usr/local/etc/nginx/.htpasswd;
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            include fastcgi_params; # include extra FCGI params
    } 
}


Thanks nogmaals voor de hint - blijkbaar precedence toch niet goed gedaan }:O