Как включить IPv6 на VDS с установленным Nginx на примере этого сайта и улучшить работу Интернета 🙂
Профессиональная настройка MikroTik
Без предоплаты
Telegram: @Engineer_MikroTik
Активируем IPv6 у оператора и получаем IPv6 адрес и шлюз
nano /etc/network/interfaces
Добавляем настройку IPv6 в конфигурацию
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto ens3
iface ens3 inet static
address 185.209.30.39
netmask 255.255.255.0
gateway 185.209.30.1
dns-nameservers 8.8.8.8
iface ens3 inet6 static
address 2a0d:8480:0:23f::1
netmask 64
gateway fe80::1
dns-nameserver 2001:4860:4860::8888
Включаем поддержку в общей конфигурации
nano /etc/nginx/sites-available/default
Добавляем listen [::]:80 default_server;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
И включаем в конфигурации конкретного сайта
nano /etc/nginx/sites-enabled/mikrotik.conf
Добавляем listen [::]:443 ssl; и listen [::]:80;
server {
server_name xn----7sba7aachdbqfnhtigrl.xn--p1ai;
root /var/www/mikrotik;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/mikrotik.rf$fastcgi_script_name;
}
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/xn----7sba7aachdbqfnhtigrl.xn--p1ai/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xn----7sba7aachdbqfnhtigrl.xn--p1ai/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = xn----7sba7aachdbqfnhtigrl.xn--p1ai) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name xn----7sba7aachdbqfnhtigrl.xn--p1ai;
listen 80;
listen [::]:80;
return 404; # managed by Certbot
}