📜 ⬆️ ⬇️

Nginx + IPv6

Recently wrote a topic about IPv6 support in Windows 7 / Vista / XP (this is here ). I wanted to do IPv6 support on my server, where sites are hosted, in the end, that's what happened.

I have a server under FreeBSD, used HE.net to get an IPv6 address on the server, here is the config for configuring this tunnel in /etc/rc.conf :

ipv6_gateway_enable="YES" ipv6_enable="YES" gif_interfaces="gif0" gifconfig_gif0="_IP_ 72.52.104.74" ipv6_ifconfig_gif0="2001:470:1f04:***::2" #  IPv6 ipv6_defaultrouter="2001:470:1f04:***::1" #   HE.net  IPv6. 

Now there was a question about web server support, IPv6 addressing. I use a bunch of nginx + apache 2.2, here's an excerpt of the server in the nginx config:

 server { listen 80 default; listen [::]:80 default; server_name _; location /nginx_status { stub_status on; access_log off; allow all; } location / { proxy_pass http://127.0.0.1:81; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_send_lowat 12000; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } location ~* \.(jpeg|jpg|gif|png|css|js|pdf|txt|tar|tar.gz|zip|ico|swf|rss)$ { root /usr/local/www/static/$host; access_log off; expires off; } } 

As you can see, the listen [::] line has been added : 80 default; . This will enable your nginx to listen to all IPv6 addresses.
')
By default, such an entry can be added to one server section. The implication is probably the fact that in IPv6 each site will be on its IPv6 address.

In order for each server {} to have its own IPv6 address, add the listen [2001: 470: 1f04: *** :: 3]: 80 . Naturally, such addresses should be alias for your main interface.

Then you need to make an entry in the DNS of your domains that are hosted.

I made a record like this:

 * IN AAAA 2001:470:1f04:***::2 

Because I have all the domains on the same server and I didn’t bother with the issue of each IPv6 site, I just made:

IPv6 Network -----------> IPv6 ServerIP ---------> proxying to 127.0.0.1 IPv4 (where Apache is spinning with the usual settings for IPv4).

Total, having registered it, I received availability of all my domains from an IPv6 network.

For each domain in the ServerAlias ​​apache I have assigned a subdomain ipv6.name_domera.ru. Well, I created symbolic links for the domain in my design (see root / usr / local / www / static / $ host;). In this folder I have symbolic links for all domains and subdomains on my server.

PS Hurry many hosting providers and hosting panels began to support IPv6 out of the box. Most domains could work there and there, then the transition to IPv6 would not be so painful.

PS IPv6 traffic appeared on sites, probably due to the addition of sites that support IPv6 to directories.

Source: https://habr.com/ru/post/94819/


All Articles