How to set gitlab's boundle nginx to avoid the conflict with an existing nginx - gitlab

I want to use a non-bundled nginx ,I overwrite /etc/gitlab/gitlab.rb set
nginx['enable'] = false,then I excute the commands:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
I find that the bundled nginx is still started,and it occupy the 80 port;
I launch the existing nginx,and I get:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
after,I think another way,I can change the port of bundle nginx ,like 8088;
I overwrite /etc/gitlab/gitlab.rb set:nginx['listen_port'] = 8888,then I reconfigure and restart gitlab;
But I find the port is not changed;I open the file '/var/opt/gitlab/nginx/conf/gitlab-http.conf',the main code like these:
server {
listen *:80;
...
...
the bundle nginx still listen to the 80 port;
I don't know how to resolve the confilct between existing nginx and bundle nginx;any hints are appreciated!

I have fixed it...because of my forgetting uncomment the code.

Related

Nginx start failed - how I can repair that problem?

I'm a little bit newbie. I've got started server few months ago. Everything was okay but now on server I can't even echo something. How Can I repair nginx server?
My debian
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
root#debian:/home/maly#
and nginx version
nginx version: nginx/1.14.2
that's my status for nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: failed (Result: exit-code) since Sat 2021-11-06 19:34:43 CET; 17min ago
Docs: man:nginx(8)
lis 06 19:34:41 debian nginx[17186]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address al
lis 06 19:34:41 debian nginx[17186]: nginx: [emerg] bind() to [::]:80 failed (98: Address alrea
lis 06 19:34:42 debian nginx[17186]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address al
lis 06 19:34:42 debian nginx[17186]: nginx: [emerg] bind() to [::]:80 failed (98: Address alrea
lis 06 19:34:42 debian nginx[17186]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address al
lis 06 19:34:42 debian nginx[17186]: nginx: [emerg] bind() to [::]:80 failed (98: Address alrea
lis 06 19:34:43 debian nginx[17186]: nginx: [emerg] still could not bind()
lis 06 19:34:43 debian systemd[1]: nginx.service: Control process exited, code=exited, status=1
lis 06 19:34:43 debian systemd[1]: nginx.service: Failed with result 'exit-code'.
lis 06 19:34:43 debian systemd[1]: Failed to start A high performance web server and a reverse
and there's my try to start a nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
The error states to [::]:80 failed, which means that another process on your system is already using port 80. A port can only be occupied by a single process simultaneously, which means you will either have to
close the process running on port 80 (there‘s several ways on how to check which process is using that port, google it for your OS) or
start using Nginx on another port 80 (which is not recommended, since webservers usually run on port 80).

Gitlab ist overlaying all subdomains and even my entire nginx.config

I am pretty new in those server / cloud dev things.
So I rented a vServer and started playing around. First with nginx. I made my own config and all went well, getting the right html files on the right sub-/domains:
server {
listen 80;
server_name beispiel.de;
location / {
root /var/www/beispiel;
index index.html;
}
}
server{
listen 80;
server_name gitlab.beispiel.de;
location / {
root /var/www/beispiel/gitlab;
index index.html;
}
}
Then I wanted to run my own git repo via gitlab, and I installed it like shown this tutorial:
https://www.howtoforge.com/tutorial/how-to-install-gitlab-on-debian-8/#install-the-prerequisites
Gitlab is running smooth. But my problem is now, that it overlays all subdomains as well as the domain itself. My config I wrote earlier seems skipped by some kind of second nginx, installed with gitlab.
I tried to stop it by service nginx stop but as I tried to service nginx start again this was the response:
Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
So I htop-ed and saw that nginx processes where still runnung. I killed them, but they always autostarted again.
systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Tue 2019-12-17 14:58:43 CET; 3min 48s ago
Process: 13257 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile
/run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1539 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited,
status=1/FAILURE)
Process: 1537 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited,
status=0/SUCCESS)
Main PID: 13321 (code=exited, status=0/SUCCESS)
Dec 17 14:58:40 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] bind() to 0.0.0.0:80
failed (98: Address already...use)
Dec 17 14:58:41 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] bind() to 0.0.0.0:80
failed (98: Address already...use)
Dec 17 14:58:41 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] bind() to 0.0.0.0:80
failed (98: Address already...use)
Dec 17 14:58:42 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] bind() to 0.0.0.0:80
failed (98: Address already...use)
Dec 17 14:58:42 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] bind() to 0.0.0.0:80
failed (98: Address already...use)
Dec 17 14:58:43 v2201912109976104637.goodsrv.de nginx[1539]: nginx: [emerg] still could not bind()
Dec 17 14:58:43 v2201912109976104637.goodsrv.de systemd[1]: nginx.service: control process exited,
code=exited status=1
Dec 17 14:58:43 v2201912109976104637.goodsrv.de systemd[1]: Failed to start A high performance web
server and a reverse pro...rver.
Dec 17 14:58:43 v2201912109976104637.goodsrv.de systemd[1]: Unit nginx.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
I don't know what to do.
Can anyone help?
Kindly,
a noob :)
After hours of googling and trying I stumbled about this link in gitlab.rb file:
https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server
It explains how to use the by your own installed nginx web server instead.
This solved my problem.
From the error logs, it looks that Old Nginx process is already using the 80 port.
Try /etc/init.d/nginx stop or systemctl stop nginx or /usr/sbin/nginx -s stop to stop old process.

Failed to start httpd server: Address already in use

Surely I know that same question is already posted here. However, when I searched it, the status is different from mine and I cannot understand the answers. Therefore I post my problem here. Sorry for duplicating issues.
My homepage suddenly doesn't work and I found out that it failed to start httpd service. Following image is the result when I command 'sudo service httpd start'
Starting httpd: (98)Address already in use: AH00072: make_sock: could
not bind to address [::]:80 (98)Address already in use: AH00072:
make_sock: could not bind to address 0.0.0.0:80 no listening sockets
available, shutting down AH00015: Unable to open logs
[FAILED]
restart doesn't work also.
$ sudo service httpd restart
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: AH00072: make_sock: could not bind
to address [::]:80 (98)Address already in use: AH00072: make_sock:
could not bind to address 0.0.0.0:80 no listening sockets available,
shutting down AH00015: Unable to open logs
[FAILED]
What should I do to restart httpd service and revive my homepage?
Error 98 usually occurs when some webserver is using the port, here 80, or
The clean release port/address was not done.
If port is being used by other webserver, shutdown the server. You can find out which service is using port 80 by
netstat -pan |grep 80
and then shutdown the service.
If the port was not released upon unclean shutdown of server, then
sudo service networking restart
to release address/port combination from bind. This usually fixes error 98 for me.
I have the same problem. So i looked to netstat:
sudo netstat -tulpn | grep :80
and received:
tcp6 0 0 :::80 :::* LISTEN 7836/docker-proxy
after killing process:
sudo kill 7836
Files defined inside conf.d would have Listen port as 80 along with repetitive declaration of Listen port in httpd.conf which can cause this issue.
Seems port 80 is used by some other process, it can be checked by "netstat -anp|grep :80" Or assign a new available port to the Listen directive in httpd.conf and restart httpd.
Your httpd server is already started. Try restarting the service instead of starting it again:
sudo service httpd restart

Not able to restart nginx

I try to restart my nginx server by the command.
sudo service nginx restart.
It gives me a error
* Restarting nginx nginx[fail]
When I check in error.log it provides me with the error
2016/04/24 06:01:45 [emerg] 12852#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/24 06:01:45 [emerg] 12852#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/24 06:01:45 [emerg] 12852#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/24 06:01:45 [emerg] 12852#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/24 06:01:45 [emerg] 12852#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2016/04/24 06:01:45 [emerg] 12852#0: still could not bind()
2016/04/24 06:13:49 [alert] 15033#0: mmap(MAP_ANON|MAP_SHARED, 52428800) failed (12: Cannot allocate memory)
How to fix this?
You already have a process that listens on that port. It might be apache for example, or another web server. Close that and start nginx

Nginx running or not?

I was surprised because the:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
when starting Nginx, so I supposed that Nginx or other was running in the port. I've tested with:
lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 13557 www-data 8u IPv4 100729 0t0 TCP *:http (LISTEN)
nginx 13558 www-data 8u IPv4 100729 0t0 TCP *:http (LISTEN)
so yes, Nginx was working and in fact web pages are running. All perfect but...not!
How can be possible this?
service nginx status
[FAIL] nginx is not running ... failed!
Not running? But I can't start any other instance because it's running! What's happening?
The same when restarting:
service nginx restart
Restarting nginx: Enter PEM pass phrase:
Enter PEM pass phrase:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Thanks in advance.
Check if nginx is running with:
ps aux | grep nginx
if nginx process exists, then it's running for sure. What you verified with lsof only proves that 80 port is occupied by certain process (for instance, apache httpd, or some other http servers). If nginx process is not running and yet 80 port is being used, which also explains why you can't start your nginx. In this scenario, you need to lookup in your process list to see which web server is already running. Kill it and restart nginx, it should be then working fine.

Resources