Nginx allows file download even with error 403 forbidden

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have setup a new centos 7.
I have installed
yum install php72u-fpm
yum install nginx -y



Next I did was to change the root folder in the config file in /etc/nginx/nginx.conf. to /var/www/html.



server_name _;
root /var/www/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location /


error_page 404 /404.html;
location = /40x.html


error_page 500 502 503 504 /50x.html;
location = /50x.html

}


Next I created a new folder /var/www/html/test
and I gave nginx the permission chown -R nginx.nginx /var/www/html/test/
So then I got to my http://.../test/ I get 403 forbidden and I check the error log what I get is this.



2018/04/11 14:43:47 [error] 24229#0: *10 directory index of "/var/www/html/test/" is forbidden, client: *.*.*.*, server: _, request: "GET /test/ HTTP/1.1", host: "*.*.*.*"


But to my surprise when I run this command for e.g. http://.../test/page1.php it gets download to my local machine this is definitely a security issue right? How to block this from happening?







share|improve this question




















  • Do you want to protect all of the files in the test directory or all files with a .php extension?
    – Richard Smith
    Apr 11 at 14:15










  • I want to protect all the files just like apache? Can that be done ?
    – user8012596
    Apr 11 at 16:59














up vote
1
down vote

favorite












I have setup a new centos 7.
I have installed
yum install php72u-fpm
yum install nginx -y



Next I did was to change the root folder in the config file in /etc/nginx/nginx.conf. to /var/www/html.



server_name _;
root /var/www/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location /


error_page 404 /404.html;
location = /40x.html


error_page 500 502 503 504 /50x.html;
location = /50x.html

}


Next I created a new folder /var/www/html/test
and I gave nginx the permission chown -R nginx.nginx /var/www/html/test/
So then I got to my http://.../test/ I get 403 forbidden and I check the error log what I get is this.



2018/04/11 14:43:47 [error] 24229#0: *10 directory index of "/var/www/html/test/" is forbidden, client: *.*.*.*, server: _, request: "GET /test/ HTTP/1.1", host: "*.*.*.*"


But to my surprise when I run this command for e.g. http://.../test/page1.php it gets download to my local machine this is definitely a security issue right? How to block this from happening?







share|improve this question




















  • Do you want to protect all of the files in the test directory or all files with a .php extension?
    – Richard Smith
    Apr 11 at 14:15










  • I want to protect all the files just like apache? Can that be done ?
    – user8012596
    Apr 11 at 16:59












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have setup a new centos 7.
I have installed
yum install php72u-fpm
yum install nginx -y



Next I did was to change the root folder in the config file in /etc/nginx/nginx.conf. to /var/www/html.



server_name _;
root /var/www/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location /


error_page 404 /404.html;
location = /40x.html


error_page 500 502 503 504 /50x.html;
location = /50x.html

}


Next I created a new folder /var/www/html/test
and I gave nginx the permission chown -R nginx.nginx /var/www/html/test/
So then I got to my http://.../test/ I get 403 forbidden and I check the error log what I get is this.



2018/04/11 14:43:47 [error] 24229#0: *10 directory index of "/var/www/html/test/" is forbidden, client: *.*.*.*, server: _, request: "GET /test/ HTTP/1.1", host: "*.*.*.*"


But to my surprise when I run this command for e.g. http://.../test/page1.php it gets download to my local machine this is definitely a security issue right? How to block this from happening?







share|improve this question












I have setup a new centos 7.
I have installed
yum install php72u-fpm
yum install nginx -y



Next I did was to change the root folder in the config file in /etc/nginx/nginx.conf. to /var/www/html.



server_name _;
root /var/www/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location /


error_page 404 /404.html;
location = /40x.html


error_page 500 502 503 504 /50x.html;
location = /50x.html

}


Next I created a new folder /var/www/html/test
and I gave nginx the permission chown -R nginx.nginx /var/www/html/test/
So then I got to my http://.../test/ I get 403 forbidden and I check the error log what I get is this.



2018/04/11 14:43:47 [error] 24229#0: *10 directory index of "/var/www/html/test/" is forbidden, client: *.*.*.*, server: _, request: "GET /test/ HTTP/1.1", host: "*.*.*.*"


But to my surprise when I run this command for e.g. http://.../test/page1.php it gets download to my local machine this is definitely a security issue right? How to block this from happening?









share|improve this question











share|improve this question




share|improve this question










asked Apr 11 at 11:57









user8012596

207




207











  • Do you want to protect all of the files in the test directory or all files with a .php extension?
    – Richard Smith
    Apr 11 at 14:15










  • I want to protect all the files just like apache? Can that be done ?
    – user8012596
    Apr 11 at 16:59
















  • Do you want to protect all of the files in the test directory or all files with a .php extension?
    – Richard Smith
    Apr 11 at 14:15










  • I want to protect all the files just like apache? Can that be done ?
    – user8012596
    Apr 11 at 16:59















Do you want to protect all of the files in the test directory or all files with a .php extension?
– Richard Smith
Apr 11 at 14:15




Do you want to protect all of the files in the test directory or all files with a .php extension?
– Richard Smith
Apr 11 at 14:15












I want to protect all the files just like apache? Can that be done ?
– user8012596
Apr 11 at 16:59




I want to protect all the files just like apache? Can that be done ?
– user8012596
Apr 11 at 16:59















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436992%2fnginx-allows-file-download-even-with-error-403-forbidden%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f436992%2fnginx-allows-file-download-even-with-error-403-forbidden%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay