Unfortunately, NGIX cannot be started. When I run the systemctl status nginx command, the following message appears:
× 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 Fri 2024-03-08 07:06:36 CST; 1h 14min ago
Docs: man:nginx(8)
Process: 27329 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 27330 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 42ms
Mar 08 07:06:33 vmi1695712.contaboserver.net systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 08 07:06:33 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:34 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:34 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:35 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:35 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)
Mar 08 07:06:36 vmi1695712.contaboserver.net nginx[27330]: nginx: [emerg] still could not bind()
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Mar 08 07:06:36 vmi1695712.contaboserver.net systemd[1]: Failed to start A high performance web server and a reverse proxy server.
My site file for Discourse:
# Default server configuration
#
server {
# listen 80 default_server;
# listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name forum.ictsharks.com;
location / {
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
I’ve checked it several times, but I can’t figure out where the error is.
Sorry, I’m a beginner with Linux / NGINX / Docker things. Any advice would be appreciated. Thank you.
The instructions suggest commenting them, so I did:
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
# - "80:80" # http
# - "443:443" # https
I understand DNS records, https and certificates. Only the rest is new to me.
Don’t worry, I know how to google and I’m a fast learner
As I stated, I believe the other NGIX (the one for wordpress) works in a container together with MySQL, and Wordpress.
This is what I get by running docker ps command:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ca4cbec2c88 local_discourse/app "/sbin/boot" 51 minutes ago Up 15 minutes app
4a3ebdd9f5b5 nginx:1.15.12-alpine "nginx -g 'daemon of…" 20 hours ago Up 15 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp webserver
42c4211a2fb6 wordpress:5.1.1-fpm-alpine "docker-entrypoint.s…" 2 days ago Up 15 minutes 9000/tcp wordpress
5b588a7435ad mysql:8.0 "docker-entrypoint.s…" 2 days ago Up 15 minutes 3306/tcp, 33060/tcp db
That would be why the external nginx cannot boot, as the ports are taken by the internal one. You probably need to shut that container down and transfer it’s config for Wordpress to the outer nginx layer.
Also, those are separate containers, the nginx is separate from MySQL and WordPress.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ca4cbec2c88 local_discourse/app "/sbin/boot" 3 hours ago Up 2 hours app
42c4211a2fb6 wordpress:5.1.1-fpm-alpine "docker-entrypoint.s…" 2 days ago Up 2 hours 9000/tcp wordpress
5b588a7435ad mysql:8.0 "docker-entrypoint.s…" 2 days ago Up 2 hours 3306/tcp, 33060/tcp db
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 418/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 462/sshd: /usr/sbin
tcp6 0 0 :::22 :::* LISTEN 462/sshd: /usr/sbin
udp 0 0 127.0.0.53:53 0.0.0.0:* 418/systemd-resolve