Nginx is running but not serving sites
We recently installed nginx version 1.17 on a new machine. sites-available
The 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.d
to store a variety of default
configurations. This configuration matches all incoming requests and takes over the processing of all requests and responses.
How nginx configuration works
Nginx sites-available
keeps configurations located in the directory private and does not route them to the Internet. Adding configuration to sites-enabled
the directory will make it publicly available.
Nginx allows us to support multiple location configuration files. The second way to configure domains: conf.d
directories.
The difference here is: conf.d
any 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-enabled
the folder:
$ nano /etc/nginx/nginx.conf
We are interested in nginx's virtual host configuration. Nginx will probably search for configuration in the conf.d
and sites-enabled
directories. 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-available
and sites-enabled
directories, conf.d
the 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.
Related Articles
Detailed explanation of the implementation methods of SSO single sign-on in three
Publish Date:2025/03/18 Views:190 Category:NETWORK
-
Single Sign On (SSO) is not unfamiliar to us. For large systems, using SSO can reduce a lot of trouble for users. Take Baidu for example. Baidu has many subsystems - Baidu Experience, Baidu Knows, Baidu Library, etc. If we need to enter a u
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