Nginx File Configuration and Logs (Part 3)

Nginx File Configuration and Logs (Part 3)

Introduction:

after installing and going to Nginx directory /etc/nginx we can see Nginx file Like, nginx.config and sites-available file and other important files

each file of this has a role and task to make Nginx correct jobs.

in this article, I will explain important files to make correct Nginx and handle all requests without any problem.

all parts of Nginx Articles?:

Nginx Files:

  • if we go to this path by terminal /etc/nginx we can see by default the following files

to access nginx directory. in Linux Os
root@ubuntu-16gb-hel1-1:/etc/nginx# cd /etc/nginx/
        

to see all files inside Nginx directory you can use the following command

root@ubuntu-16gb-hel1-1:/etc/nginx# ls

        

the output from the above command :

you can see here all the nginx file.
No alt text provided for this image

we will start with nginx.config:

  • etc/nginx.config:

all of the Nginx main configuration?you can find it here ,?

we can write our own configuration in this file and Nginx setup here.?

we can write HTTP block here to define our configuration in all Nginx system.

in the next section will write our configuration and talk about each block in Nginx configuration

  • /etc/nginx/sites-available/

here we can write site domain and server block with configuration to specific application, and when reload Nginx nginx.config will read all files inside etc/sites-available/ folder.

but to enable this feature you must write the following configuration inside nginx.config

nginx by default will create the same file in sites-enabled with the same name.

include /etc/nginx/sites-enabled/fileName;        


  • etc/nginx/sites-enabled/

when create a new directory you must link with configuration file by site-enable

you must linked sites-available/ with sites-enabled/ because /nginx.config need linked with /sites-enabled/ to enabled your configuration

  • /etc/nginx/snippets

if we have any repeated configuration between services we can include inside this file and share it with other configuration files.

okay now we know where we can make our configration but where I can see my logs

when install nginx will created file in /var/log/nginx

inside this directory, we can find all logs from Nginx services.

okay lets go to above directory and see what the logs provide services

to go to above directory you can use the following command:

cd /var/log/nginx/        

and to see all files in /var/log/nginx write the follwoing command:

ls        

after that, you can see this file in output.

No alt text provided for this image

i will explain two important files in the logs section in this article.

  • /var/log/nginx/access.log

every request received to Nginx will record in this file like the following image.

No alt text provided for this image
we can changed this file from configuration file.

  • /var/log/nginx/error.log

each Nginx error will record here like the follwoing image.

No alt text provided for this image
i have one error just :)

Conclusion:

in this article, we know now what is the files job in Nginx and where we need each files in the Nginx system.?

and now we know where we can find our logs of each request in our system, with know where we can define our configuration.?

Nginx is easy to use and I will explain about configuration in the next article

all parts of Nginx Articles?:

references:

要查看或添加评论,请登录

Abd-Alrhman Alkraien的更多文章

  • Base Entity and Audit entity with?JPA

    Base Entity and Audit entity with?JPA

    Introduction: When creating any web application and wanting to connect it with DB, we will add id as a column inside…

    1 条评论
  • Java 8 — Stream APIs

    Java 8 — Stream APIs

    overview When Java 8 came into this world, it comes to provide us with more features, flexibility, and comfortable to…

  • Java with Jackson and JSON

    Java with Jackson and JSON

    Introduction: every developer knows about JSON, and many developers use Json format with API requests or responses. So…

    2 条评论
  • Liquibase Tutorial

    Liquibase Tutorial

    Introduction: Sometimes we need to create a database and put fake data inside it, when running the application, we can…

    1 条评论
  • Element collection Vs One to Many in JPA and hibernate

    Element collection Vs One to Many in JPA and hibernate

    Introduction: Inside any project will have a database for saving and fetching the data from it, and will save the data…

  • Java history from Java 1.0 to Java 18

    Java history from Java 1.0 to Java 18

    Introduction: From this article, you can see the version of java from the first to the latest version. And what are the…

  • Immutability in Java

    Immutability in Java

    What is Immutability?!! An object is considered immutable if its state cannot change after it is constructed. Maximum…

    2 条评论
  • Logging Spring requests using aspect

    Logging Spring requests using aspect

    Introduction: In any web application we need logging request and response, We can do it using Log4j in java, but in…

  • Aspect Object Programing with Spring boot?Example

    Aspect Object Programing with Spring boot?Example

    Introduction: In the previous article, we talked about Aspect and if you read the previous article you should know the…

  • Aspect object programming with Spring?boot

    Aspect object programming with Spring?boot

    Introduction: The programming in the world is changing every day and the projects are bigger in the last few days. so…

    1 条评论

社区洞察

其他会员也浏览了