# Nginx HTTP Basic Authentication

**URL:** https://forum.shopware.com/t/nginx-http-basic-authentication/62603
**Category:** Installation / Einstieg
**Created:** [25. Oktober 2019 um 08:33 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603 "2019-10-25T08:33:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Ciatronical](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@Ciatronical](https://forum.shopware.com/u/Ciatronical)
#### Post date: [25. Oktober 2019 um 08:33 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/1 "2019-10-25T08:33:40Z")

</div>

Hey All,

ich möchte meine Shopwareseite so lange sie im Aufbau ist schützen.  
Das klappt soweit auch, doch leider wird der Admin-Bereich auch geschützt.  
Dort muss ich dann endlos lang Username und Passwd eingeben.

Ich möchte als lediglich das Frontend schützen.

Ich habe schon etwas mit den Nginx-Direktiven experimentiert doch leider erfolglos.

```
##subroot public ##

location / {
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/nginxpasswd;
    try_files $uri /index.php$is_args$args;
}
location /recovery/install {
    #auth_basic "Restricted";
    #auth_basic_user_file /etc/nginx/nginxpasswd;
    index index.php;
    try_files $uri /recovery/install/index.php$is_args$args;
}
location /recovery/update {
    #auth_basic "Restricted";
    #auth_basic_user_file /etc/nginx/nginxpasswd;
    index index.php;
    try_files $uri /recovery/update/index.php$is_args$args;
}
location /admin/ {
    auth_basic off;
}
location /admin#/ {
    auth_basic off;
}

```

Wie kann ich Nginx dazu bewegen lediglich das Fontend zu schützen.

---

<div class="post-metadata">

### Author: ![drakon](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/drakon/32/7724_2.png) [@drakon](https://forum.shopware.com/u/drakon)
#### Post date: [25. Oktober 2019 um 08:43 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/2 "2019-10-25T08:43:39Z")

</div>

Man kann sich doch in seinen Favoriten einen Link der Form

[https://User:Password@www.example.tld/backend](https://User:Password@www.example.tld/backend)

abspeichern. Dann hat sich das mit der mauellen Eingabe erledigt. Funktioniert zumindest in Chrome und Firefox.

---

<div class="post-metadata">

### Author: ![Ciatronical](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@Ciatronical](https://forum.shopware.com/u/Ciatronical)
#### Post date: [25. Oktober 2019 um 11:42 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/3 "2019-10-25T11:42:32Z")

</div>

Funktioniert leider nicht.

Immer wenn eine Datei nachgeladen wird fragt der Browser nach Benutzer und Passwd.

---

<div class="post-metadata">

### Author: ![drakon](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/drakon/32/7724_2.png) [@drakon](https://forum.shopware.com/u/drakon)
#### Post date: [25. Oktober 2019 um 12:06 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/4 "2019-10-25T12:06:41Z")

</div>

Das ist nicht normal. Entweder der Server oder der Browser verwirft die Info dann immer wieder. Hier genügt das einmal am Tag, selbst den Browser zwischendurch schließen, stört nicht.

Man muss natürlichCookies und den ganzen Rest zulassen. Evtl. stört ein Browser-Plugin. Da ist weniger oft auch mehr.

---

<div class="post-metadata">

### Author: ![Shopwareianer](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Shopwareianer](https://forum.shopware.com/u/Shopwareianer)
#### Post date: [25. Oktober 2019 um 18:04 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/5 "2019-10-25T18:04:36Z")

</div>

```
....
    # htaccess
    auth_basic "Restricted Content";
    auth_basic_user_file /dein/pfad/.htpasswd;
...
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

```

&nbsp;

---

<div class="post-metadata">

### Author: ![Ciatronical](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@Ciatronical](https://forum.shopware.com/u/Ciatronical)
#### Post date: [26. Oktober 2019 um 16:08 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/6 "2019-10-26T16:08:39Z")

</div>

Funktioniert leider auch nicht.

Htaccess ist unter /admin aktiviert.

Wenn ich: [https://meinShop.de/admin](https://meinShop.de/admin) eingebe soll der Passwortschutz nicht aktiv sein.

Wenn ich [https://meinShop.de](https://meinShop.de) eingebe soll der Passwortschutz aktiviert sein.

Viele Dank

Ronny

---

<div class="post-metadata">

### Author: ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)
#### Post date: [26. Oktober 2019 um 16:11 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/7 "2019-10-26T16:11:04Z")

</div>

Ja, du müsstest auch die API rausnehmen aus dem htaccess Schutz. Der Admin ist ja nur eine Applikation die mit der API spricht.

---

<div class="post-metadata">

### Author: ![Ciatronical](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@Ciatronical](https://forum.shopware.com/u/Ciatronical)
#### Post date: [26. Oktober 2019 um 16:19 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/8 "2019-10-26T16:19:33Z")

</div>

Juhu, das war es…

Danke und einen schönen Abend.

---

<div class="post-metadata">

### Author: ![developer1](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@developer1](https://forum.shopware.com/u/developer1)
#### Post date: [11. Juli 2022 um 10:31 UTC](https://forum.shopware.com/t/nginx-http-basic-authentication/62603/9 "2022-07-11T10:31:19Z")

</div>

Hello @Moritz_Naczenski @Ciatronical, Könnten Sie bitte die Details/Schritte zur Lösung dieses Problems erläutern.
