I am having trouble with my nginx server not wanting to start. could someone with the appropriate knowledge try to diagnose my error code and give me some kind of guidance as to how I can fix my issue? This is my first time posting so if you need anymore information please let me know. Thanks (:
michael#productionserver1:~$ sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
michael#productionserver1:~$ 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 Thu 2016-07-14 05:50:29 EDT; 16s ago
Process: 3754 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/
Process: 2269 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=ex
Process: 3598 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, statu
Process: 5641 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exit
Main PID: 3600 (code=exited, status=0/SUCCESS)
lines 1-8/8 (END)
I got this when running " nginx -t " nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed: (13 Permission denied) 2016/07/14 07:32:23 [warn] 6060#6060: the "user" directive makes sense only if the master process runs with super-suer privileges, ignored in /etc/nginx/nginx.conf:1 2016/07/14 07:32:23 [emerg] 6060#6060: a duplicate default server for 0.0.0.0:44 3 in /etc/nginx/sites-enabled/example.com:34 nginx: configuration file /etc/nginx/nginx.conf text failed
Related
Getting error in Nginx --> 404 page not found. I have task to host the website using the nginx. I have read the basic things and I have host the website, but getting the error. The following are the trouble shooting:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu ; 17h ago
Process: 1482 ExecReload=/usr/sbin/nginx -s reload (code=exited, status=0/SUCCESS)
Process: 32393 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 32389 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 32387 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 32395 (nginx)
CGroup: /system.slice/nginx.service
├─ 1484 nginx: worker process
├─ 1485 nginx: worker process
└─32395 nginx: master process /usr/sbin/nginx
curl -vv https://testing.abc.com
getting ssl certificate information.
curl -k https://testing.abc.com
# getting error --> 404 page not found
I have check fallowing things
in the conf.d folder i have check root path of website folder,
in the main nginx.conf file i have mention the root path.
remove the nginx packages and again install it, but still getting the same error
This is what it brings when you check nginx status
[root#ttproxyapp conf.d]# service nginx status
Redirecting to /bin/systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
sudo systemctl stop apache2
sudo systemctl start nginx
should work since looks like the port is in use (with apache probably)
It realy looks like your NGINX ins't running. nginx -s reload is just working if there is a running instance and therfore a PID-file.
Please check the result of the following command.
[root#localhost conf.d]# sudo ps -elf | grep nginx
Should be something like
1 S root 88262 1 0 80 0 - 13143 sigsus 23:47 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
5 S nginx 88263 88262 0 80 0 - 13257 ep_pol 23:47 ? 00:00:00 nginx: worker process
0 R root 88265 69227 0 80 0 - 28178 - 23:47 pts/1 00:00:00 grep --color=auto nginx
You need at least! the master process and the worker process! If there is no process start your instance by typing
sudo /bin/systemctl start nginx.service OR sudo service nginx start
Check your processlist after running the command.
After you have started the NGINX service there should be PID-file located at
/var/run/nginx.pid and sudo systemctl status nginx.service should printout something like
[root#localhost conf.d]# systemctl status nginx.service
● nginx.service - NGINX Plus - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-03-14 23:47:13 EDT; 5min ago
Docs: https://www.nginx.com/resources/
Process: 88232 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 88260 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Process: 88251 ExecStartPre=/usr/libexec/nginx-plus/check-subscription (code=exited, status=0/SUCCESS)
Main PID: 88262 (nginx)
Tasks: 2
Memory: 1.7M
CGroup: /system.slice/nginx.service
├─88262 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─88263 nginx: worker process
Mar 14 23:47:13 localhost.localdomain systemd[1]: Starting NGINX Plus - high performance web server...
Mar 14 23:47:13 localhost.localdomain systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) after start: No such file or directory
Mar 14 23:47:13 localhost.localdomain systemd[1]: Started NGINX Plus - high performance web server.
I am running NGINX Plus but it doesn't matter in this case.
there is maybe an apache server running. you must stop that apache server order run the Nginx server.
sudo systemctl stop apache2
sudo systemctl start nginx
I'm new to using Nginx as a reverse proxy, and here is my /etc/nginx/conf.d/default.conf:
server {
listen 80;
location /myip/ {
proxy_pass http://checkip.dyndns.com/;
proxy_set_header Host http://checkip.dyndns.com/;
}
}
and this line in /etc/nginx/nginx.conf is active:
include /etc/nginx/conf.d/*.conf;
I was expecting to see a page about my IP address when I visited http://localhost/myip/, but I got 404 instead. Any ideas why so? Meanwhile http://localhost is correctly showing nginx's welcoming page.
More details about my env:
Clean debian VM in GCP
Nginx installed via sudo apt install nginx
server status (sudo systemctl status nginx) is looking good:
● 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 Sun 2020-03-08 01:27:50 UTC; 6min ago
Docs: man:nginx(8)
Process: 4237 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exite
d, status=0/SUCCESS)
Process: 3342 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCES
S)
Process: 4242 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 4239 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 4244 (nginx)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/nginx.service
├─4244 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─4245 nginx: worker process
└─4246 nginx: worker process
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Stopped A high performance web server and a reverse proxy server.
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 08 01:27:50 marqeta-proxy-test systemd[1]: Started A high performance web server and a reverse proxy server.
I can't restart nginx server. the following error encountered. I suspect the cause could be that there's another service running on port 80.
I tried listing down all services running on port 80. But it does not show any.
root#ubuntu:/# 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#ubuntu:/# 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 Sun 2019-04-21 15:21:14 EDT; 53s ago
Docs: man:nginx(8)
Process: 121217 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run
Process: 120160 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, stat
Process: 121540 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exi
Main PID: 120162 (code=exited, status=0/SUCCESS)
Apr 21 15:21:13 ubuntu systemd[1]: Starting A high performance web server and a reverse proxy s
Apr 21 15:21:14 ubuntu nginx[121540]: nginx: [emerg] "listen" directive is not allowed here in
Apr 21 15:21:14 ubuntu nginx[121540]: nginx: configuration file /etc/nginx/nginx.conf test fail
Apr 21 15:21:14 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 21 15:21:14 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 21 15:21:14 ubuntu systemd[1]: Failed to start A high performance web server and a reverse
I am learning how to set up a load balancer, using nginx on AWS.
I set up a basic ubuntu 18.04 server on AWS, and then did the following:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install nginx -y
I then replaced /etc/nginx/nginx.conf with the following:
upstream backend {
server xxx.24.20.11;
server xxx.24.20.12;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
I then tried restarting the nginx server by doing:
sudo service nginx stop
sudo service nginx start
but I'm getting the error message:
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
So, I did
systemctl status nginx.service
And here's what I got:
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-04-03 01:13:27 UTC; 23s ago
Docs: man:nginx(8)
Process: 1822 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1748 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1865 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 1752 (code=exited, status=0/SUCCESS)
Apr 03 01:13:27 load-balancer.xxxx.com systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 03 01:13:27 load-balancer.xxx.com nginx[1865]: nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/nginx.conf:2
Apr 03 01:13:27 load-balancer.xxx.com nginx[1865]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 03 01:13:27 load-balancer.xxx.com systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 03 01:13:27 load-balancer.xxx.com systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 03 01:13:27 load-balancer.xxx.com systemd[1]: Failed to start A high performance web server and a reverse proxy server.
I looked at two separate tutorials, and they both use the "upstream" directive. Any ideas?
Edit:
I returned nginx.conf to its original format:
sudo cp /etc/nginx/nginx.original /etc/nginx/nginx.conf
Then, I did the following:
sudo su
echo > /etc/nginx/sites-available/load-balancer.conf
I then added the following to /etc/nginx/sites-available/load-balancer.conf
http {
upstream backend {
server docker-one.xxxxxxx.com;
server docker-two.xxxxxxx.com;
}
server {
listen 80;
server_name load-balancer.xxxxxxx.com;
location / {
proxy_pass http://backend;
}
}
}
load-balancer.xxxxxxx.com is the domain name that I am using for testing, and the docker-one and docker-two are the two domains that will be running the actual web app.
I then did a symlink:
ln -s /etc/nginx/sites-available/load-balancer.conf /etc/nginx/sites-enabled/
then I rebooted the server. When it was back up, I did the following:
sudo service nginx stop
sudo service nginx start
I got an error message telling me the nginx service failed, so I did:
systemctl status nginx.service
Which gave me the following error:
● 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-04-03 19:42:34 UTC; 19s ago
Docs: man:nginx(8)
Process: 1549 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Apr 03 19:42:34 load-balancer.xxxxxxx.com systemd[1]: Starting A high performance web server and a reverse proxy server...
Apr 03 19:42:34 load-balancer.xxxxxxx.com nginx[1549]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 03 19:42:34 load-balancer.xxxxxxx.com systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 03 19:42:34 load-balancer.xxxxxxx.com systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 03 19:42:34 load-balancer.xxxxxxx.com systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Overwriting whole nginx.conf you deleted http context. upstream is only allowed inside http {} block as per https://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream
Debian/ubuntu uses /etc/nginx/sites-available/* for site definitions, thats where you need to create your own config file, one per vhost if needed. And then enable it so it becomes symlinked to /etc/nginx/sites-enabled/*. Or for simplicity, use /etc/nginx/sites-available/default as existing config file, make your changes there. Save original, until you get it working. And reload nginx after said changes. Restore original /etc/nginx/nginx.conf also, ofcourse.