Nginx support ipv6 configuration method under Linux system
- 2020-12-18 02:03:49
- OfStack
1. Check to see if the existing nginx supports ipv6
You need to execute the following command to see if the existing nginx supports ipv6, if it has -- with-ipv6 in the argument, then it does, if not, then it does not, and you need to recompile nginx.
# Here the nginx Path to your actual nginx The boot file path shall prevail
/usr/local/nginx-1.14.0/sbin/nginx -V
2. Recompile nginx for ipv6
1. Download the corresponding nginx installation package;
2. Unzip the nginx installation package;
3. Enter the installation file of nginx after unzipping, execute the./configure command first, then add the parameters obtained by /usr/local/ ES31en-1.14.0 /sbin/ ES33en-ES34en above, and then add the parameter -- ES35en-ES36en6 to execute;
4, execute make command, do not execute make install command, otherwise the original nginx to overwrite;
5. Backup the nginx execution file under the original path:
sudo cp /usr/local/nginx-1.14.0/sbin/nginx /usr/local/nginx-1.14.0/sbin/nginx.old
6. After make, enter the objs folder under installation folder;
cd objs
7. After stopping the original nginx service and overwriting the original nginx execution file, start nginx service:
sudo /usr/local/nginx-1.14.0/sbin/nginx -s stop
sudo cp nginx /usr/local/nginx-1.14.0/sbin/nginx
sudo /usr/local/nginx-1.14.0/sbin/nginx
Supplement:
Listen for BOTH IPV4 and IPV6
server {
....
listen [::]:80;
...
}
Only to monitor IPV6
server {
....
listen [::]:80 default ipv6only=on;
...
}
Listen for the specified IPV6 address
server {
....
listen [3608:f0f0:3002:31::1]:80;
...
}