skip to Main Content

I’m faced with a strange problem on iOS devices when I try to access a website placed behind an Nginx proxy in http/2 with an Apache backend also in http/2.

On iOS devices – and only on iOS devices – I have a ERR_INVALID_RESPONSE displayed on the browser (regardless of the browser used: Safari, Chrome, … All have the same behavior). There is absolutly no problem with desktop browsers (Linux or Windows) or with Android devices. The problem seems to be on the underlaying network stack on iOS devices ?…

Browser <---> Nginx with http/2 <---> Apache with http/2
[ ERR_INVALID_RESPONSE ]

If I disable http/2 on the Apache backend, all is working fine… This behavior is not depending on the website (same problem on many sites with same successfull workaround).

Browser <---> Nginx with http/2 <---> Apache with http/1.1 (http/2 DISABLED)
[ OK ]

It seems that I’m not the only one with this problem (https://community.ovh.com/t/resolu-vps-sous-plesk-site-innaccessible-sous-iphone-et-ipad/42227)

But except to disable http/2 on the Apache backend, I don’t find any explanation of the root cause of the problem.

Any ideas ?…

2

Answers


  1. Chosen as BEST ANSWER

    Solution and root cause found here : https://serverfault.com/questions/818535/nginxapache2letsencrypt-with-iphone-cannot-display-page

    iOS 10+ doesn't support having an Upgrade header in the response if original request is already in http/2. The solution is to hide the Upgrade header provided by the Apache server due to the upgrade of the Nginx to Apache request (Nginx send an http/1.1 request witch is upgraded in http/2 by Apache).

    Now facing the same/similar issue on iOS 12 with nginx 1.16.0 proxying to apache enabled with http2. Workaround is to disable http2 on nginx, the right solution is described here https://trac.nginx.org/nginx/ticket/915 or https://trac.nginx.org/nginx/ticket/1150 - adding proxy_hide_header Upgrade; will solve that. With Upgrade header (probably only) the iOS cannot handle "protocol upgrade request" together with that the request is already in http2.

    The same proxy on apache 2.4 and mod_proxy works ok as this header is not forwarded to client as default.


  2. I was getting ERR_INVALID_RESPONSE in iOS Safari, but "cannot parse response" in iOS Chrome.

    Same: reverse proxy Nginx-Apache server.

    Per a non-accepted answer on the above link, I changed nothing in HTTP/2, only added this line in the Nginx config and restarted:

    Inside this statement:

    location / {
       proxy_pass http://127.0.0.1:8080;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
    
    }
    

    Add this line:

       proxy_hide_header Upgrade;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search