Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Nginx is running, but not serving.
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
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Mar 13, 2021 5:50 am    Post subject: [Solved] Nginx is running, but not serving. Reply with quote

I did fresh re-install of nginx.
Conf-file is default.
Code:
 ~ $ sudo /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Code:
 ~ $ ps aux | egrep 'nginx|PID'
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     12259  0.0  0.0  16864  1616 ?        Ss   12:46   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12260  0.0  0.0  17104  2116 ?        S    12:46   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

Code:
 ~ $ sudo netstat -tulpen | grep :80
tcp        0      0 127.0.0.1:80            0.0.0.0:*               LISTEN      0          103891     12259/nginx: master


Code:
cat /var/www/localhost/htdocs/index.html
Hello, world!

Code:
 ~ $ ls -all /var/www/localhost/htdocs/
total 4
drwxr-xr-x  3 root  root   41 Mar 13 00:17 .
drwxr-xr-x  7 root  root  120 Mar 13 12:11 ..
-rw-r--r--  1 nginx nginx  14 Mar 13 00:17 index.html
drwxr-xr-x 11 nginx nginx 282 Mar 12 22:46 rutorrent

Code:
 ~ $ curl http://localhost
- no any response

Code:
www-servers/nginx-1.19.8::gentoo was built with the following:
USE="aio http http-cache http2 pcre pcre-jit ssl threads -debug -ipv6 -libatomic (-libressl) -rtmp (-selinux) -vim-syntax" LUA_SINGLE_TARGET="luajit" NGINX_MODULES_HTTP="access auth_basic autoindex browser charset empty_gif fastcgi geo grpc gzip limit_conn limit_req map memcached mirror proxy referer rewrite scgi split_clients ssi upstream_hash upstream_ip_hash upstream_keepalive upstream_least_conn upstream_zone userid uwsgi -addition -auth_ldap -auth_pam -auth_request -brotli -cache_purge -dav -dav_ext -degradation -echo -fancyindex -flv -geoip -geoip2 -gunzip -gzip_static -headers_more -image_filter -javascript -lua -memc -metrics -mogilefs -mp4 -naxsi -perl -push_stream -random_index -realip -secure_link -security -slice -slowfs_cache -spdy -sticky -stub_status -sub -upload_progress -upstream_check -vhost_traffic_status -xslt" NGINX_MODULES_MAIL="-imap -pop3 -smtp" NGINX_MODULES_STREAM="-access -geo -geoip -geoip2 -javascript -limit_conn -map -realip -return -split_clients -ssl_preread -upstream_hash -upstream_least_conn -upstream_zone"


Change number of worker_processes to 7.
Code:
 ~ $ ps aux | egrep 'nginx|PID'
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     12856  0.0  0.0  16864  2996 ?        Ss   12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12857  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12858  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12859  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12860  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12861  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12862  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx    12863  0.0  0.0  17104  2172 ?        S    12:58   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
There is no worker processes only master. WTF?

Last edited by Perfect Gentleman on Fri Mar 19, 2021 2:19 am; edited 1 time in total
Back to top
View user's profile Send private message
Tom_
Guru
Guru


Joined: 20 May 2004
Posts: 444
Location: France

PostPosted: Sat Mar 13, 2021 7:58 am    Post subject: Reply with quote

Have you checked the nginx logs ? Nginx could be complaining about a permission issue.

If you add "-v" to the curl command, do you get additional information ?

If you try to access the port 80, does it work ?

Code:
nc localhost 80 -v
or
telnet localhost 80


Do you have a firewall running on this server ?
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Mar 13, 2021 8:07 am    Post subject: Reply with quote

Quote:
Have you checked the nginx logs ?
Of course, no errors, just info.

Code:
 ~ $ curl -v http://localhost
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.75.0
> Accept: */*


I have neither nc nor telnet .
But ssh says
Code:
 ~ $ ssh -vvv -p 80 127.0.0.1
OpenSSH_8.5p1-hpn15v1, OpenSSL 1.1.1j  16 Feb 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 80.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
debug1: Local version string SSH-2.0-OpenSSH_8.5p1-hpn15v1


Quote:
Do you have a firewall running on this server ?
No

Imho, the main issue is that there are only master processes and no worker processes.
Back to top
View user's profile Send private message
halcon
l33t
l33t


Joined: 15 Dec 2019
Posts: 629

PostPosted: Sat Mar 13, 2021 11:13 am    Post subject: Reply with quote

Perfect Gentleman wrote:
Code:
$ sudo /usr/sbin/nginx -t

Perfect Gentleman wrote:
Imho, the main issue is that there are only master processes and no worker processes.

Why not launch it via OpenRC (or systemd if you have it)?
_________________
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Mar 13, 2021 11:22 am    Post subject: Reply with quote

halcon wrote:
Why not launch it via OpenRC (or systemd if you have it)?

Why have you decided so? Just read wiki 'bout nginx.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3136

PostPosted: Sat Mar 13, 2021 11:29 am    Post subject: Reply with quote

Do you have a vhost configured?
Back to top
View user's profile Send private message
halcon
l33t
l33t


Joined: 15 Dec 2019
Posts: 629

PostPosted: Sat Mar 13, 2021 11:54 am    Post subject: Reply with quote

Perfect Gentleman,

I found that explanation
Code:
By running nginx with the -t option, it will validate the configuration file without actually starting the nginx daemon

So, I guess, you meant that after that you launched nginx as a service? OK. I just have a habit to launch most programs first without OpenRC, to check everything, and only after that to start the service.
_________________
A wife asks her husband, a programmer:
- Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?
He comes back with 6 cartons of milk.
- Why did you buy 6 cartons of milk?
- They had eggs.
Back to top
View user's profile Send private message
Perfect Gentleman
Veteran
Veteran


Joined: 18 May 2014
Posts: 1249

PostPosted: Sat Mar 13, 2021 12:20 pm    Post subject: Reply with quote

szatox wrote:
Do you have a vhost configured?

No, it's default configuration. It should work.
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