LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   nginx fails to listen on specific IPv6 address (https://www.linuxquestions.org/questions/linux-newbie-8/nginx-fails-to-listen-on-specific-ipv6-address-4175704851/)

lattimro 12-12-2021 10:09 AM

nginx fails to listen on specific IPv6 address
 
Ubuntu 20.04.3
nginx version: nginx/1.18.0 (Ubuntu)

Hello,

I just followed a simple procedure to set ngnix to listen to a specific IPv6 address https://geekflare.com/enable-ipv6-nginx-apache/ and we encountered an error. Below are some relevant info:

ip a |g inet6
Code:

inet6 ::1/128 scope host
inet6 fe80::6e35:7039:2681:db1f/64 scope link noprefixroute
inet6 fe80::42:d3ff:feaf:2ad/64 scope link

changed /etc/nginx/sites-available/default to listen to IPv6 address, note the '[]' were included:

Code:

listen [fe80::6e35:7039:2681:db1f]:80 default_server;
no other servers listen on p:80:

Code:

lsof -i :80 | grep LISTEN
and succesfully fails:

Code:

nginx[16359]: nginx: [emerg] bind() to [fe80::6e35:7039:2681:db1f]:80 failed (22: Invalid argument)
found out something weird at least at my level of understanding I do not know if it is related but I do not think that is what ping should normally reply:
Code:

ping -I wlp4s0 fe80::6e35:7039:2681:db1f
ping: Warning: source address might be selected on device other than: wlp4s0
PING fe80::6e35:7039:2681:db1f(fe80::6e35:7039:2681:db1f) from :: wlp4s0: 56 data bytes

However
Code:

ping fe80::6e35:7039:2681:db1f%wlp4s0
PING fe80::6e35:7039:2681:db1f%wlp4s0(fe80::6e35:7039:2681:db1f%wlp4s0) 56 data bytes
64 bytes from fe80::6e35:7039:2681:db1f%wlp4s0: icmp_seq=1 ttl=64 time=0.060 ms
64 bytes from fe80::6e35:7039:2681:db1f%wlp4s0: icmp_seq=2 ttl=64 time=0.104 ms

works but I do not know how to add this workaround to /etc/nginx/sites-available/default


Thanks!

bathory 12-13-2021 11:23 AM

Quote:

I just followed a simple procedure to set ngnix to listen to a specific IPv6 address https://geekflare.com/enable-ipv6-nginx-apache/ and we encountered an error. Below are some relevant info:

ip a |g inet6
Code:

inet6 ::1/128 scope host
inet6 fe80::6e35:7039:2681:db1f/64 scope link noprefixroute
inet6 fe80::42:d3ff:feaf:2ad/64 scope link

changed /etc/nginx/sites-available/default to listen to IPv6 address, note the '[]' were included:

Code:

listen [fe80::6e35:7039:2681:db1f]:80 default_server;

no other servers listen on p:80:

Code:

lsof -i :80 | grep LISTEN

and succesfully fails:

Code:

nginx[16359]: nginx: [emerg] bind() to [fe80::6e35:7039:2681:db1f]:80 failed (22: Invalid argument)

AFAIK ipv6 addresses starting with fe80 are link-local addresses. I guess you cannot assign such an address to a webserver.
You may give a valid ipv6 address to your interface and test.

lattimro 12-13-2021 01:39 PM

I see, I did not know that, thanks!
then how come IPv4 can listen on local address?

ondoho 12-18-2021 04:15 AM

Quote:

Originally Posted by lattimro (Post 6309213)
I see, I did not know that, thanks!
then how come IPv4 can listen on local address?

You very clearly did not even start reading the article linked.
tl;dr: link-local is not the same as local. IPv6 can listen on (most) local addresses.


All times are GMT -5. The time now is 08:48 AM.