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

feature: new global setting options to enable SNI-forward to external domains #1697

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

alexAubin
Copy link
Member

@alexAubin alexAubin commented Aug 11, 2023

The problem

For various scenarios, it would be nice to be able to have SNI-based forwarding of HTTPS traffic (ie without decrypting the traffic) to another machine. For example:

  • hosting several Yunohost behind a single IP (or a single YunoHot + other stuff like NAS / whatever, behind a single IP)
  • more advanced case such as having a VPN on a YunoHost server on whatever provider, but which serves a purpose of "exposing" a Yunohost server which otherwise cannot be exposed because behind too many layers of networks etc

Solution

Introduce a new setting to "enable SNI based forwarding" + configure a mapping of domain:IPv4

The whole thing tweaks nginx's configuration and use nginx's ssl_preread stuff : https://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html

2023-08-11-230653_1366x768_scrot

PR Status

Somewhat tested but should be propreply re-tested

Also we should :

  • check that the SNI-forwarded domains are not YunoHost domains
  • technical tweak to add in nginx regenconf to forget about old .forward80.conf (cf FIXME in code)
  • ??? think about other funky cases idk

How to test

...

Copy link
Member

@zamentur zamentur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Aleks ping me on the chat, i find some times to make a review.

Feel free to decide to ignore some of my comments...

conf/nginx/sni_forward.conf Outdated Show resolved Hide resolved
conf/nginx/sni_forward.conf Outdated Show resolved Hide resolved
proxy_set_header X-Forwarded-Uri $request_uri;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is HTTP and HTTPS behaviour the same for logs in the final server (the one with the service) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be important to know it, cause fail2ban could ban the reverse proxy server...

share/config_global.toml Show resolved Hide resolved
share/config_global.toml Show resolved Hide resolved
@alexAubin
Copy link
Member Author

(The remaining blocker is to properly configure the IP header thingy)

@Tagadda
Copy link
Contributor

Tagadda commented Apr 21, 2024

IP header thingy, wat dat iz??

@alexAubin
Copy link
Member Author

alexAubin commented Apr 22, 2024

cf #1697 (comment) and the X-Real-IP header

Basically if you enable SNI-forward, all traffic on the "server B" appears as coming from "server A"'s IP ... which means fail2ban, if triggered, will ban server A entirely.

Nginx has some option somewhere to assume that the real IP is not the IP from the raw packets, but a specific HTTP header, typically X-Real-IP, which is set by "server A" (the front server)

But since this is something to be configured on "server B" and not "server A", we probably need a new global setting such as "This server is behind an SNI reverse proxy" which adds the proper nginx tweak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
3 participants