Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect configures host header second time #45

Open
zcatav opened this issue Aug 25, 2023 · 0 comments
Open

Redirect configures host header second time #45

zcatav opened this issue Aug 25, 2023 · 0 comments

Comments

@zcatav
Copy link

zcatav commented Aug 25, 2023

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.

@zcatav zcatav changed the title Redirect configures host header twice Redirect configures host header second time Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant