Nginx Error Only From Mobile Devices

Recently I deployed a Phoenix application live on a Ubuntu 14.04 LTS and everything rendered fine until I tried on my mobile device. I instantly hit the “Welcome to Nginx” page.

Naturally I started looking at logs, both application logs and Nginx logs but no errors were being thrown.

Next I started debugging the device itself. I put my mobile device onto the wifi network which my computer was using that rendered the site fine and instantly the mobile device started rendering the site. So this is a mobile network problem? Tethering my computer through my phone confirmed this.

Futher searching brought me to the realization that the mobile device is using IPV6! So how can we get Nginx to accept this?

Within your nginx.conf change your listen to allow IPV6.

So basically change this:

1
2
3
4
5
6
7
8
9
server { 
  listen       80;
  server_name  domain2.com www.domain2.com;
  access_log   logs/domain2.access.log  main;

  location / {
    ...
  }
}

To this:

1
2
3
4
5
6
7
8
9
server { 
  listen       [::]:80;
  server_name  domain2.com www.domain2.com;
  access_log   logs/domain2.access.log  main;

  location / {
    ...
  }
}

Using [::]:80 allows IPV6 now and we are rendering on mobile correctly.