Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to configure nginx?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
pmam
Veteran
Veteran


Joined: 30 Dec 2013
Posts: 1145

PostPosted: Wed Mar 18, 2015 11:22 am    Post subject: How to configure nginx? Reply with quote

I am trying to build Home webserver - I installed nginx according this: http://wiki.gentoo.org/wiki/Nginx
and it looks ok - all testing noted in Troubleshooting chapter passed ok.
But when I am trying to access with web browser to the http://localhost I get an error: '403 Forbidden' -
It looks that need to adjust /etc/nginx/nginx.conf to my local host data - here the default config:
Code:
server {
                listen 127.0.0.1;
                server_name localhost;
 
                access_log /var/log/nginx/localhost.access_log main;
                error_log /var/log/nginx/localhost.error_log info;
 
                root /var/www/localhost/htdocs;

Maybe there is a permission issue?
In addition - I saw in other docs (non-Gentoo) - that need to set /etc/nginx/sites-available and /etc/nginx/sites-enabled -
I did not see any comment in above Gentoo's wiki - If need it please, explain or point me to relevant link?
_________________
“You can take our property, our sweet homes, even our cloths...
But don't touch the streets, Ah, That's NO, NO, NO!
The streets are our @world's compilable kernel ...”
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14169

PostPosted: Thu Mar 19, 2015 1:33 am    Post subject: Reply with quote

What does the nginx error log show?
Back to top
View user's profile Send private message
pmam
Veteran
Veteran


Joined: 30 Dec 2013
Posts: 1145

PostPosted: Thu Mar 19, 2015 7:59 pm    Post subject: Reply with quote

Hu Hello,

Here localhost.error_log and one line of localhost.access_log:
Code:
2015/03/17 19:03:50 [info] 5463#0: *1 client 127.0.0.1 closed keepalive connection
2015/03/17 19:08:18 [error] 5596#0: *1 directory index of "/var/www/localhost/htdocs/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2015/03/17 19:08:38 [info] 5596#0: *1 client 127.0.0.1 closed keepalive connection
2015/03/17 19:09:15 [error] 5670#0: *1 directory index of "/home/mg/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2015/03/17 19:09:19 [error] 5670#0: *1 directory index of "/home/mg/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2015/03/17 19:09:40 [info] 5670#0: *1 client 127.0.0.1 closed keepalive connection
2015/03/18 12:09:28 [error] 2368#0: *1 directory index of "/var/www/localhost/htdocs/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2015/03/18 12:09:49 [info] 2368#0: *1 client 127.0.0.1 closed keepalive connection

Code:
127.0.0.1 - - [19/Mar/2015:21:55:41 +0200] "GET / HTTP/1.1" 403 346 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0 SeaMonkey/2.31" "-"


Thanks
_________________
“You can take our property, our sweet homes, even our cloths...
But don't touch the streets, Ah, That's NO, NO, NO!
The streets are our @world's compilable kernel ...”
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5917

PostPosted: Thu Mar 19, 2015 10:20 pm    Post subject: Reply with quote

You haven't enabled the directory index module for that path and you have no index files for nginx to display. It's working exactly as it's supposed to.
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 5689
Location: Removed by Neddy

PostPosted: Fri Mar 20, 2015 12:07 am    Post subject: Reply with quote

what are the permissions and owners for: /var/www/localhost/htdocs

Code:

ls -l
total 4
drwxr-xr-x 4 nginx nginx 4096 Aug 13  2013 localhost

_________________
The best argument against democracy is a five-minute conversation with the average voter
Great Britain is a republic, with a hereditary president, while the United States is a monarchy with an elective king
Back to top
View user's profile Send private message
pmam
Veteran
Veteran


Joined: 30 Dec 2013
Posts: 1145

PostPosted: Fri Mar 20, 2015 10:26 am    Post subject: Reply with quote

Ant P. & Naib,

According your replies I see that I miss something... I thought all directories has been set by installation.
This is the first time I am building webserver so please try to be much detailed as you can -
Please correct me if I am wrong:
In order to test virtual localhost, according the default config, need to create a directory called:
/var/www/localhost/htdocs and add a new user called nginx and set permissions - Please note the right command for this permissions?

Please advise what need to do regarding 'index module' -
need to create directory or file called index under /var/www/localhost/htdocs?

Can you recommend on more detailed wiki?

Thanks
_________________
“You can take our property, our sweet homes, even our cloths...
But don't touch the streets, Ah, That's NO, NO, NO!
The streets are our @world's compilable kernel ...”
Back to top
View user's profile Send private message
pmam
Veteran
Veteran


Joined: 30 Dec 2013
Posts: 1145

PostPosted: Sun Mar 22, 2015 12:37 pm    Post subject: Reply with quote

Ok – I see that nginx's installation has already created /var/www/localhost/htdocs directory,
and added group and user called nginx, with the appropriated permissions -
so I only needed to add a file called index.html under that directory, as Ant P. suggested, with some text like:
Code:
<html>
<head>
<title>www.example.com</title>
</head>
<body>
<h1>Success: You Have Set Up a Virtual Host</h1>
</body>
</html>

and I can access and see this message.
I would recommend to add such file to installation – It would save me some time, and to you, as well...
Now I need to learn and carefully consider all security aspects, in order to be in the safe side, before meeting the big bad Internet...
I would appreciate tips and recommendations of a good links for a 'security beginner' like me.

Thanks you all
_________________
“You can take our property, our sweet homes, even our cloths...
But don't touch the streets, Ah, That's NO, NO, NO!
The streets are our @world's compilable kernel ...”
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5917

PostPosted: Sun Mar 22, 2015 6:36 pm    Post subject: Reply with quote

As long as it's only serving static files there won't be security problems, you'd have to do a lot of work to make it unsafe.
Back to top
View user's profile Send private message
pmam
Veteran
Veteran


Joined: 30 Dec 2013
Posts: 1145

PostPosted: Mon Mar 23, 2015 1:11 pm    Post subject: Reply with quote

Quote:
As long as it's only serving static files there won't be security problems

I see that dynamic files, means database and all maintenance scripts, PHP etc, but -
If I have 'Sign in' and 'Login' module -Is it still 'static' or 'dynamic'?

I have a simple setup: NAT router with LAN -
Please let me know if I need to read 'Gentoo Security Handbook' with the relevant issues, like:
File Permissions, Firewall, Ports Forwarding etc - or it is not quite necessary?

Thanks
_________________
“You can take our property, our sweet homes, even our cloths...
But don't touch the streets, Ah, That's NO, NO, NO!
The streets are our @world's compilable kernel ...”
Back to top
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 2659

PostPosted: Mon Mar 23, 2015 2:04 pm    Post subject: Reply with quote

pmam wrote:
Ok – I see that nginx's installation has already created /var/www/localhost/htdocs directory,
and added group and user called nginx, with the appropriated permissions -
so I only needed to add a file called index.html under that directory, as Ant P. suggested, with some text like:
Code:
<html>
<head>
<title>www.example.com</title>
</head>
<body>
<h1>Success: You Have Set Up a Virtual Host</h1>
</body>
</html>

and I can access and see this message.
I would recommend to add such file to installation – It would save me some time, and to you, as well...
Pmam,
It's all well described in the docs. And gninx also has its own forum where you'll find much useful help and information.
Back to top
View user's profile Send private message
rodia
n00b
n00b


Joined: 29 Dec 2005
Posts: 11
Location: 43° 36 North, 1° 26 West

PostPosted: Sun Apr 19, 2015 9:57 pm    Post subject: How to configure nginx? [SOLVED] Reply with quote

Hi all,

Pmam, yes this absence of index static file could be confusing but I guess it forces, for good, to go through the nginx docs as charles17 linked.

I think you were expected something more like an empty index listing showing the root directory and for this you have the autoindex module:
autoindex on;

Code:
server {
                listen 127.0.0.1;
                server_name localhost;
                root /var/www/localhost/htdocs;

                autoindex on;
#...
}


Just adding some useful info to that thread that I didn't find very easily the first time I was setting up nginx.
_________________
Having the choice is a choice that we do.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum