0

I want to block direct access to some extensions like .phtml on my site through the NGINX. so I searched and found some solutions but none of them worked for me!

some of them are : How to deny with 404 on nginx https://serverfault.com/questions/137907/how-to-restrict-access-to-directory-and-subdirs Replace NGINX 403 for deny with a different error response code

and unfortunately none of (deny all; and return 403;) worked.

and here is my server part in nginx configuration :

    server {
    listen       *******:80;
    listen       127.0.0.1:80;
    #listen       [::1]:80;
    server_name  $hostname ******;

    root   /var/www/html;
    index  index.html index.htm index.php;

location ~ /\.phtml {
    return 403;
    deny all;
}       

# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/usr/local/php55/sockets/webapps.sock;
}

    include /etc/nginx/nginx-info.conf;
    include /etc/nginx/webapps.conf;
}

so please help me and tell me what is wrong with the .phtml part!

thank you so much

============================================ Edit :

Hi again I searched a lot and I finally find out that the code I used requires "ngx_http_access_module" and it is not installed on my system. I have installed nginx through the DirectAdmin CustomBuild 2 and it appears that the module is not installed.

I tried to install it but I need pre-built package for that module to install by this code :

"--add-module=/usr/local/directadmin/custombuild/custom/nginx/module-directory"

and when I used nginx package it returned

 configuring additional modules

adding module in /usr/local/directadmin/custombuild/custom/nginx-1.8.0/src/http/modules/ngx_http_access_module.c ./configure: error: no /usr/local/directadmin/custombuild/custom/nginx-1.8.0/src/http/modules/ngx_http_access_module.c/config was found

please help me to install that module :)

Community
  • 1
  • 1
user1925409
  • 51
  • 1
  • 1
  • 4

0 Answers0