We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Nginx password protect directory
Nginx password protect directory
Hi,
I am trying to password protect a directory on my server with Nginx + Apache.
I have added the following lines to /home/admin/conf/web/nginx.conf inside the server { } definition.
The directory is now password protected, however php files inside the directory are downloaded instead of executed when accessing them.
What am I missing there to tell Nginx to forward php requests as it should? and by "as it should" I mean like it does in the default config for document root.
Thanks
I am trying to password protect a directory on my server with Nginx + Apache.
I have added the following lines to /home/admin/conf/web/nginx.conf inside the server { } definition.
Code: Select all
location ~ ^/secret {
root /home/admin/web/domain.com/public_html;
auth_basic "Administrator Login";
auth_basic_user_file /home/admin/web/domain.com/public_html/secret/.htpasswd;
What am I missing there to tell Nginx to forward php requests as it should? and by "as it should" I mean like it does in the default config for document root.
Thanks
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Nginx password protect directory
I think you're trying to run php files through nginx, which is not possible. Protect your folder via apache (.htaccess).
Re: Nginx password protect directory
It is possible, I just need the right config instructions to tell Nginx how to process php files.
Protecting my folder via Apache is not a solution because Nginx is the main web server here.
I can find many example of configuring nginx for php5-fpm or FastCGI but I'm not sure how VestaCP is doing it so I don't want to risk breaking my whole setup, that's why I am asking here to get direction on how to do it the same way VestaCP is handling it.
Protecting my folder via Apache is not a solution because Nginx is the main web server here.
I can find many example of configuring nginx for php5-fpm or FastCGI but I'm not sure how VestaCP is doing it so I don't want to risk breaking my whole setup, that's why I am asking here to get direction on how to do it the same way VestaCP is handling it.
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Nginx password protect directory
Nginx is used as a kind of proxy. You must protect the directory via apache.
nginx - php-fpm support is comming in next release.
nginx - php-fpm support is comming in next release.