How to view nginx log on Centos (docker)?

How to view nginx log on Centos (docker)?

I get 502, 504 Nginx Gateway errors, so I want to see nginx log.
Can you tell me command line, how to view nginx log on Centos (docker)?

Discourse runs inside a Docker container, which is essentially like a virtual machine. All components are self-contained so it is rather difficult to lose anything. To see the logs that the NGINX server produces, such as access and error, you’ll need to go to the logs folder inside the container’s shell.

Exercise caution while inside the shell, as this can break your instance.

Enter your container’s shell using these commands. You can skip su - if you’re already root.

su -
cd /var/discourse
./launcher enter app
cd /var/log/nginx

Open the file error.log in your preferred terminal text editor (I prefer nano only because I’m not an expert, you’ll need to install it first).

nano error.log

Locate the last line (the latest entry) of the file by pressing ^V (CTRL-V). When finished, press ^X to return to shell.

When finished, run exit to return to your CentOS root shell.

I got this error when I followed your instructions

-bash: cd: /var/log/nginx: No such file or directory

1 Like

Go to the /var/log directory and reply with the results of the ls command.

1 Like

I did as you instructed, returned the following results,
What do I do next to see the nginx log?

[root@45 discourse]# cd /var/log/
[root@45 log]# ls
anaconda       cron-20211101       maillog-20211017   ppp               spooler-20211024
audit          cron-20211107       maillog-20211024   rhsm              spooler-20211101
boot.log       dmesg               maillog-20211101   secure            spooler-20211107
btmp           dmesg.old           maillog-20211107   secure-20211017   tallylog
btmp-20211101  firewalld           messages           secure-20211024   tuned
chrony         grubby              messages-20211017  secure-20211101   wtmp
cron           grubby_prune_debug  messages-20211024  secure-20211107   yum.log
cron-20211017  lastlog             messages-20211101  spooler           yum.log-20200101
cron-20211024  maillog             messages-20211107  spooler-20211017  yum.log-20210114

I have seen Nginx,
but do you know: what command to get into nginx log?

See

 /var/discourse/shared/standalone/logs/var-log/nginx
1 Like

@pfaffman

i did like you, but i still get the error:

[root@45 var-log]# cd /var/discourse/shared/standalone/logs/var-log/nginx
-bash: cd: /var/discourse/shared/standalone/logs/var-log/nginx: No such file or directory
[root@45 var-log]# /var/discourse/shared/standalone/logs/var-log/nginx
-bash: /var/discourse/shared/standalone/logs/var-log/nginx: No such file or directory

What if you do an ls in the var-log directory that you are in?

Try it again, but replace the folder logs with log, like below. I also got the error on my machine.

/var/discourse/shared/standalone/log/var-log/nginx
1 Like