# 404 error when adding htpasswd auth (nginx)

**URL:** https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743
**Category:** Product Support
**Created:** [June 15, 2017, 5:34pm UTC](https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743 "2017-06-15T17:34:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![saturno](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@saturno](https://forum.mautic.org/u/saturno)
#### Post date: [June 15, 2017, 5:34pm UTC](https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743/1 "2017-06-15T17:34:42Z")

</div>

Hi there,  
  
  
  
I tried to secure my mautic installation by adding a htpasswd on its login page.  
  
  
  
I’m using Nginx, so the configuration setting has been placed as following:

Code:

location /s/login { auth\_basic "Restricted!"; auth\_basic\_user\_file /path/to/.htpasswd; }

  
It works. When entering my Mautic site it prompts me with the credentials popup. But when I enter the credentials I see a 404 page.  
  
And looking on the error.log this is the statement:  
"/var/www/'sitedomain.com'/htdocs/s/login" failed (2: No such file or directory)...  
  
If I remove the location and htaccess location from the config file it works fine.  
  
Does anyone have a clue here? It seems looking for content inside the '...htdocs/s/login' which doesn't seem right. But I'm not sure where to point to the correct location.

---

<div class="post-metadata">

### Author: ![saturno](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@saturno](https://forum.mautic.org/u/saturno)
#### Post date: [June 15, 2017, 5:34pm UTC](https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743/2 "2017-06-15T17:34:42Z")

</div>

Hi there,

I tried to secure my mautic installation by adding a htpasswd on its login page.

I’m using Nginx, so the configuration setting has been placed as following:

```auto
location /s/login {
 auth_basic "Restricted!";
 auth_basic_user_file /path/to/.htpasswd;
}
```

It works. When entering my Mautic site it prompts me with the credentials popup. But when I enter the credentials I see a 404 page.

And looking on the error.log this is the statement:  
“/var/www/‘[sitedomain.com](http://sitedomain.com)’/htdocs/s/login” failed (2: No such file or directory)…

If I remove the location and htaccess location from the config file it works fine.

Does anyone have a clue here? It seems looking for content inside the ‘…htdocs/s/login’ which doesn’t seem right. But I’m not sure where to point to the correct location.

---

<div class="post-metadata">

### Author: ![ninjoan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ninjoan/32/1005_2.png) [@ninjoan](https://forum.mautic.org/u/ninjoan)
#### Post date: [June 15, 2017, 9:43pm UTC](https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743/3 "2017-06-15T21:43:02Z")

</div>

I try that method a few years ago and using that method i notice yes you secure the /s/login page but also i notice some problem that affect the use of Mautic (Leads, Landing Pages, Email ) so check that all is working after doing that.

PD: I not longer use that method to secure Mautic.

---

<div class="post-metadata">

### Author: ![saturno](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@saturno](https://forum.mautic.org/u/saturno)
#### Post date: [June 20, 2017, 12:30am UTC](https://forum.mautic.org/t/404-error-when-adding-htpasswd-auth-nginx/8743/4 "2017-06-20T00:30:04Z")

</div>

Thanks, ninjoan!

I’d like to enhance the security of my login page to avoid password cracking attempts. But I indeed hope it doesn’t prevent the system to work as it should.

Does anyone on the forum has any other experience/solution to share?

Regards,

Marcos Saturno
