JIYIK CN >

Current Location:Home > Learning > NETWORK >

Nginx is running but not serving sites

Author:JIYIK Last Updated:2025/03/17 Views:

We recently installed nginx version 1.17 on a new machine. sites-availableThe configuration created in was symlinked to sites-enabled, but nginx is not serving any domain names.

The key point here is that nginx uses different directories conf.dto store a variety of defaultconfigurations. This configuration matches all incoming requests and takes over the processing of all requests and responses.

How nginx configuration works

Nginx sites-availablekeeps configurations located in the directory private and does not route them to the Internet. Adding configuration to sites-enabledthe directory will make it publicly available.

Nginx allows us to support multiple location configuration files. The second way to configure domains: conf.ddirectories.

The difference here is: conf.dany file located in the directory will be picked up by nginx and routed to the Internet. If you want to make a domain name inaccessible, you must delete the configuration for that domain from the conf.d folder.


Check nginx configuration

Check if there is a conf.d directory in /etc/nginx that contains the default configuration .

If the conf.d directory exists, you should check if nginx's configuration contains sites-enabledthe folder:

$ nano /etc/nginx/nginx.conf  

We are interested in nginx's virtual host configuration. Nginx will probably search for configuration in the conf.dand sites-enableddirectories. Depending on the order, nginx might find the "gotta catch 'em all" configuration first.

The contents of our nginx.conf file might look like this:

user www-data;  
worker_processes auto;  
pid /run/nginx.pid;

events {  
        worker_connections 768;
}

http {  
        sendfile on;
        tcp_nopush on;

        ##
        # 虚拟主机配置
        ##
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;  # <-- 如果希望“sites-enabled”工作,请确保此行有效
}

If we place configuration files for our domains in the sites-availableand sites-enableddirectories, conf.dthe default configuration from may override them.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

What multipart/form-data does in post Upload upload files

Publish Date:2025/03/18 Views:63 Category:NETWORK

Everyone has used the attribute enctype="multipart/form-data" when uploading files using a form. What is the role of multipart/form-data? Let's talk about this topic. First, let's look at a case Look at the first code   form action= "handl

About application/x-www-form-urlencoded

Publish Date:2025/03/18 Views:147 Category:NETWORK

As a data format of form, application/x-www-form-urlencoded has its own characteristics   form action= "handle.php" method= "post"    input type= "text" name= " uname"   class= " uname" /br /    input type= "text" name= "email" class=

My understanding of webservice is this

Publish Date:2025/03/18 Views:147 Category:NETWORK

Recently, I encountered such a project at work (temporarily named Project A). Project A itself was developed in PHP, but its data came from another project developed in Java (temporarily named Project B). Project A could not operate the dat

WSDL looks like this

Publish Date:2025/03/18 Views:190 Category:NETWORK

When I first started learning Webservice, I found that there were quite a lot of knowledge points involved, and each point could be a school of its own. Especially when I saw WSDL, I looked up information for a long time, but I was still a

Which technology do you choose to implement the web chat room?

Publish Date:2025/03/18 Views:61 Category:NETWORK

With the rise of HTML5 Websockets, web chat applications are becoming more and more popular. Recently, I am working on a mobile web application, the core function of which is to implement web chat on the mobile phone. Of course, the functio

Implementing a group chat room using socket.io

Publish Date:2025/03/18 Views:65 Category:NETWORK

This article will share with you an example of using socket.io to realize the function of group chat. If you want to use socket.io, you must use nodejs to implement the server, so we need to install socket.io in nodejs Install socket.io How

First contact with CGI

Publish Date:2025/03/18 Views:51 Category:NETWORK

Since I am a PHP programmer, I often have to build a PHP operating environment. The popular nginx+php environment is very popular, and the mode it adopts is the FastCGI method, so I spent some time to learn about FastCGI. CGI (Common Gatewa

Getting started with FastCGI

Publish Date:2025/03/18 Views:164 Category:NETWORK

In "First Contact with CGI", we mentioned the operating mechanisms of CGI and Server APIs, as well as their respective advantages and disadvantages. In this chapter, we will learn about FastCGI, which combines the advantages of CGI and Serv

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial