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

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.

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).

Deploy Laravel Project on Debian Server using Ngnix

So I created an application with laravel, and now I try to host it in a Debian server.
I uploaded all the project laravel found in (/ var / www / html / site)
(site) is the folder that contains all the files app, public, .env ....
Just that there is also a mybb forum that is running in (/ var / www / html / board) and that's another dev who put it so I do not want to do any wrong manipulation that might make the forum down
So before I look how to start a Laravel project on Debian, and I followed the instructions from this tutorial, (Not all because I had for example already installed, PHP 7.3, phpmyadmin)
This is how i set ( sudo vim /etc/nginx/sites-available/mydomain.com )
server {
server_name mydomain.com mydomain.com;
listen 80;
root /var/www/html/site/public;
access_log /var/log/nginx/laravel-access.log;
error_log /var/log/nginx/laravel-error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
and at the end i run this commund
sudo service nginx restart
i get this error
root#ns300976:~# sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
so next i try (systemctl status nginx.service) and i get this
root#ns300976:~# sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root#ns300976:~# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2019-11-13 06:37:35 UTC; 40s ago
Docs: man:nginx(8)
Process: 21913 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/F
Process: 21911 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, s
nov. 13 06:37:33 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 06:37:35 ns300976 nginx[21913]: nginx: [emerg] still could not bind()
nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Control process exited, code=exited status=1
nov. 13 06:37:35 ns300976 systemd[1]: Failed to start A high performance web server and a reverse pr
nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Unit entered failed state.
nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Failed with result 'exit-code'.
lines 1-17/17 (END)
next i try (journalctl -xe) and i get this
root#ns300976:~# journalctl -xe
nov. 13 06:59:12 ns300976 sshd[22318]: Failed password for root from 112.85.42.89 port 41078 ssh2
nov. 13 06:59:14 ns300976 sshd[22318]: Failed password for root from 112.85.42.89 port 41078 ssh2
nov. 13 06:59:15 ns300976 sshd[22318]: Received disconnect from 112.85.42.89 port 41078:11: [preaut
nov. 13 06:59:15 ns300`enter code here`976 sshd[22318]: Disconnected from 112.85.42.89 port 41078 [preauth]
nov. 13 06:59:15 ns300976 sshd[22318]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty
nov. 13 07:01:01 ns300976 sudo[22331]: root : TTY=pts/1 ; PWD=/root ; USER=root ; COMMAND=/usr/s
nov. 13 07:01:01 ns300976 sudo[22331]: pam_unix(sudo:session): session opened for user root by root(
nov. 13 07:01:01 ns300976 systemd[1]: Starting A high performance web server and a reverse proxy ser
-- Subject: L'unité (unit) nginx.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) nginx.service a commencé à démarrer.
nov. 13 07:01:01 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 07:01:01 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
nov. 13 07:01:04 ns300976 nginx[22340]: nginx: [emerg] still could not bind()
nov. 13 07:01:04 ns300976 sudo[22331]: pam_unix(sudo:session): session closed for user root
nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Control process exited, code=exited status=1
nov. 13 07:01:04 ns300976 systemd[1]: Failed to start A high performance web server and a reverse pr
-- Subject: L'unité (unit) nginx.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- L'unité (unit) nginx.service a échoué, avec le résultat failed.
nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Unit entered failed state.
nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Failed with result 'exit-code'.
this is the first time I have been working with Linux and looking for solutions I have suspected the apache2 which blocks the port 80
but by doing a kill process, I'm afraid to affect the forum because I do not know if it uses Apache2 for its functions
if I have to run my application via Apache, I would like to have your advice then on this
Thanks for help !
After root /var/www/html/site/public; add this
index index.php index.html index.htm index.nginx-debian.html;
I think your apache is running.check this in wchich port which is running
sudo netstat -ntpl
then kill that process
sudo kill pid(your pid)

nginx website on Ubuntu 18 not loading on public IP

I am trying to host a website via nginx on Amazon AWS EC2 Ubuntu 18.04. I started by following this tutorial. I ran sudo apt update and sudo apt install nginx. Then, I ran sudo ufw allow 'Nginx HTTP'. Running sudo ufw status returned the following;
Status: active
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
OpenSSH ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
After that I ran systemctl status nginx which returned:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: active (running) since Thu 2019-03-21 14:30:31 UTC; 1min 17s ago
Docs: man:nginx(8)
Process: 2657 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code
Process: 2644 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
Main PID: 2661 (nginx)
Tasks: 2 (limit: 1152)
CGroup: /system.slice/nginx.service
├─2661 nginx: master process /usr/sbin/nginx -g daemon on; master_pro
└─2663 nginx: worker process
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: Starting A high performance web serv
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: nginx.service: Failed to parse PID f
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: Started A high performance web serve
lines 1-15/15 (END)...skipping...
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-03-21 14:30:31 UTC; 1min 17s ago
Docs: man:nginx(8)
Process: 2657 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2644 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2661 (nginx)
Tasks: 2 (limit: 1152)
CGroup: /system.slice/nginx.service
├─2661 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─2663 nginx: worker process
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Mar 21 14:30:31 ip-172-31-29-16 systemd[1]: Started A high performance web server and a reverse proxy server.
I then tried to fix the Failed to parse PID from file /run/nginx.pid: Invalid argument error. I did that by doing mkdir /etc/systemd/system/nginx.service.d, then printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" which returned
[Service]
ExecStartPost=/bin/sleep 0.1
After that I ran sudo nano /etc/systemd/system/nginx.service.d/override.conf and inserted the above quote into there and saved it. Then sudo systemctl daemon-reload and sudo systemctl restart nginx. After that running systemctl status nginx returned this:
● 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: active (running) since Thu 2019-03-21 14:54:44 UTC; 16s ago
Docs: man:nginx(8)
Process: 2941 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 2957 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 2955 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2944 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2956 (nginx)
Tasks: 2 (limit: 1152)
CGroup: /system.slice/nginx.service
├─2956 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─2962 nginx: worker process
Mar 21 14:54:44 ip-172-31-29-16 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Mar 21 14:54:44 ip-172-31-29-16 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 21 14:54:44 ip-172-31-29-16 systemd[1]: Started A high performance web server and a reverse proxy server.
I figured everything should be working now, so I ran curl localhost and that returned
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
nginx.org.<br/>
Commercial support is available at
nginx.com.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
I believe I should also be able to access this from my home PC, so I did curl ifconfig.me to get my public IP and then I went to http://PUBLICIP, but it said This site can’t be reached.
Can someone help me fix this please?
Thanks.
Problem was my AWS security groups, I added an inbound rule to accept all TCP and now it works.

reinstall nginx if i delete /etc/nginx in centos server how to reinstall it again i am new in centos and nginx

i install nginx in my remote server but i done some error in my nginx.conf file and could not able to revert back
so it tried to remove my nginx and reconfigure it
so i used these step which is given in the link to delete my nginx
http://www.ehowstuff.com/how-to-remove-uninstall-nginx-on-centos-7-rhel-7-oracle-linux-7/
then i use yum remove nginx and again reinstall it
but when i try sudo systemctl start nginx or [root#lotto nginx]# service nginx start
its showing
Job for nginx.service failed because the control process exitenter code hereed with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
when i am using
[root#lotto nginx]# systemctl status nginx.service
showing
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
Jul 01 07:48:44 lotto systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 01 07:48:44 lotto nginx[30832]: nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:5
Jul 01 07:48:44 lotto nginx[30832]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 01 07:48:44 lotto systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 01 07:48:44 lotto systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Jul 01 07:48:44 lotto systemd[1]: Unit nginx.service entered failed state.
Jul 01 07:48:44 lotto systemd[1]: nginx.service failed.
and [root#lotto nginx]# journalctl -xe
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2016-07-01 07:48:44 EDT; 18s ago
Process: 30832 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
Process: 30830 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 14307 (code=exited, status=0/SUCCESS)
uninstall
yum remove nginx
install
In CentOS , you should using yum install ; instead of apt-get install in Ubuntu.
at last I found out the solutions by my self
I used nginx -t which shows that I don't have any syntax error in my code
Then I use
user nobody; // in my nginx.conf
This solved my problem
Thanks everyone for your help!

Cannot connect to nginx server on fedora linux (digitalocean)

I tried to set up nginx on a brand new fedora box on DigitalOcean. These are my steps
$ yum install nginx
$ systemctl enable nginx
$ systemctl restart nginx
However, it doesn't seem to work. I get the following output when running systemctl status nginx
[root#inspiredev ~]# systemctl status nginx -l
nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
Active: active (running) since Fri 2014-11-07 14:26:33 EST; 1s ago
Process: 958 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
Process: 967 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 966 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 970 (nginx)
CGroup: /system.slice/nginx.service
├─970 nginx: master process /usr/sbin/ngin
└─971 nginx: worker proces
Nov 07 14:26:33 inspiredev systemd[1]: Starting The nginx HTTP and reverse proxy server...
Nov 07 14:26:33 inspiredev nginx[966]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Nov 07 14:26:33 inspiredev nginx[966]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Nov 07 14:26:33 inspiredev systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Nov 07 14:26:33 inspiredev systemd[1]: Started The nginx HTTP and reverse proxy server.
I can't seem to figure out or where I went wrong. It'd be great if someone can help with this.
EDIT: When I go to the box's IP address, I got nothing, which is why I feel like something is not working right.
From the systemd logs, nginx service appears to be running. (the warning about the pid file not found seems endemic to many distributions).
On fedora 19/20 (systemd based), open the firewall with the following commands:
firewall-cmd --permanent --zone=public --add-service=http
systemctl restart firewalld.service
or alternatively:
firewall-cmd --permanent --zone=public --add-port=80/tcp
systemctl restart firewalld.service
The second version syntax lets you open any port/protocol combination.

Resources