Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does [::] mean in my nginx config file

Tags:

nginx

I was looking at my nginx config file I noticed two this.

server {     listen 80 default_server;     listen [::]:80 default_server;      index index.html; } 

I understand this part listen 80 default_server; it tells nginx to listen on port 80 and set that as the "default_server" but I do not understand the second line.

listen [::]:80 default_server;

It appears I am setting the default server again on port 80 but I do not really understand the [::] part of it at all.

Can someone explain to me what this configuration does?

like image 770
Subtubes Avatar asked Dec 16 '15 06:12

Subtubes


People also ask

What does 80 mean in NGINX?

If the server name is not found, the request will be processed by the default server. For example, a request for www.example.com received on the 192.168. 1.1:80 port will be handled by the default server of the 192.168. 1.1:80 port, i.e., by the first server, since there is no www.example.com defined for this port.

How do I know if my NGINX config is correct?

Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.

What is the configuration file of NGINX?

By default, the configuration file is named nginx. conf and placed in the directory /usr/local/nginx/conf , /etc/nginx , or /usr/local/etc/nginx .

Where is the nginx configuration file?

Understanding Nginx Configuration Contexts. This guide will cover the basic structure found in the main Nginx configuration file. The location of this file will vary depending on how you installed the software on your machine. For many distributions, the file will be located at /etc/nginx/nginx.conf.

What are Nginx location blocks?

What are Location Blocks? Every NGINX configuration file will be found in the /etc/nginx/ directory, with the main configuration file located in /etc/nginx/nginx.conf . NGINX configuration options are known as “directives”: these are arranged into groups, known interchangeably as blocks or contexts .

What happens if you restart Nginx and make changes?

If you’re making changes to your nginx configuration files, you are running a huge risk if you restart nginx and you made a mistake, a typo, or copied and pasted from Stackoverflow wrong. Luckily there’s an easy built-in way to test your configuration files to make sure they won’t break everything.

What are Nginx contexts?

These are the contexts that comprise the major structure of an Nginx configuration. The most general context is the “main” or “global” context. It is the only context that is not contained within the typical context blocks that look like this:


1 Answers

It is for the IPv6 configs

from the nginx docs

IPv6 addresses (0.7.36) are specified in square brackets:  listen [::]:8000; listen [::1]; 
like image 69
Camron_Godbout Avatar answered Oct 10 '22 11:10

Camron_Godbout