Http auth/htpasswd for nginx

I’m trying to nginx auth to work. Added a bash script in the autostart folder but I get error:

770#770: *2 open() “/home/devilbox/.htpasswd” failed (2: No such file or directory), client:, server: test.local, request: “GET /favicon.ico HTTP/2.0”, host: “test.local”, referrer: “https://test.local/login

Perhaps there’s a better place to put the htpasswd file? I usually store it in the /etc/nginx folder.

#! /bin/bash

echo 'Generating htpasswd file'

echo 'test:{SHA}fdsfdsfds+AifalQEIiXH1A=' >> /home/devilbox/.htpasswd

sudo chown www-data:www-data /home/devilbox/.htpasswd
sudo chmod ug=rw /home/devilbox/.htpasswd



  # PHP-FPM will not be applied to a reverse proxy!
  php_fpm: |
    # PHP-FPM Definition
    location / {
      try_files $uri $uri/ =404;

      auth_basic "Administrator’s Area";
      auth_basic_user_file /home/devilbox/.htpasswd;