YunoHost-Apps / redirect_ynh

Redirection app for YunoHost
GNU Affero General Public License v3.0
43 stars 21 forks source link

Redirect configures host header second time #45

Open zcatav opened 1 year ago

zcatav commented 1 year ago

Hi, FYI The problem described and solved at https://forum.yunohost.org/t/redirect-app-configuration/26067

Describe the bug

Hardware: VPS bought online YunoHost version: 11.2.3 (stable) I have access to my server : Through the webadmin Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

If your request is related to an app, specify its name and version: app 1.0.2~ynh1

Description of my issue I’ve a web application runs on Yunohost server. It uses port 3000 to serve.

redirect.conf 
location / {
  proxy_pass        http://127.0.0.1:3000;
  proxy_redirect    off;
  proxy_set_header  Host $host;
  proxy_set_header  X-Real-IP $remote_addr;
  proxy_set_header  X-Forwarded-Proto $scheme;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header  X-Forwarded-Host $server_name;
  proxy_set_header  X-Forwarded-Port $server_port;

  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";

  # Include SSOWAT user panel.
  include conf.d/yunohost_panel.conf.inc;
  more_clear_input_headers 'Accept-Encoding';

When I try to connect my app\ browser says: Invalid Host header. Let’s encrypt symbol shows as secure connection.

The problem is that you have caused the Host header to be included twice.

    proxy_set_header Host $host;
    include proxy_params;

Looking at the proxy_params file will show you that it was already set there. Setting it again causes the two values to be joined with a comma.

Inside that file you will find preset headers that will be used when you include that file. You do not need to repeat any of those lines in your own configuration.

ubuntu@vmtest-ubuntu2004:~$ cat /etc/nginx/proxy_params proxy_set_header Host $http_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; You can remove your own additional proxy_set_header Host $host; from the configuration.