cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Enhance Security for SysVMs Behind Reverse Proxy

Open daviftorres opened this issue 7 months ago • 6 comments

The required feature described as a wish

I’d like to propose extending the Reverse Proxy support introduced in Management servers in (https://github.com/apache/cloudstack/commit/67e2061f4b87934c863cbafc5031821ad7ef6d02) to the SysVMs as well.

As shown in the screenshot below, Management servers can now recognize (and trust) Reverse Proxy servers:

Image

This brings both security, observability, and control, by preserving the real client IP address, which makes logs significantly more useful.

Today we leverage Reverse Proxies for: WAF, Rate limiting for abusive users, DoS/DDoS protection, and SSL/TLS termination. Each of these alone is a valid reason to support Reverse Proxies in SysVMs.

The current workaround: we had to modify the SysVM template manually:

  1. Update Apache vhost config:
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 10.7.1.0/24
  1. Enable the module and restart Apache:
a2enmod remoteip
systemctl restart apache2

Feel free to ask questions and share your thoughts. I can provide details and perform tests as needed.

Keep up with the good work!!

daviftorres avatar Jun 12 '25 23:06 daviftorres

@daviftorres do you still need to add the static route inside the SSVM ?

weizhouapache avatar Jun 13 '25 06:06 weizhouapache

@weizhouapache , no. The route (discussed here https://github.com/apache/cloudstack/pull/7288) breaks my setup.

daviftorres avatar Jun 13 '25 13:06 daviftorres

@daviftorres , do you mean that we should revert the behaviour of #7288 in addtion to adding automation you describe as a workaround?

DaanHoogland avatar Jun 13 '25 14:06 DaanHoogland

@weizhouapache , based on my limited understanding of the purpose of the added route, I would say:

  • Yes, I am proposing to remove the route and add the automation for the workaround. Unless the route is required.

daviftorres avatar Jun 13 '25 14:06 daviftorres

@weizhouapache , based on my limited understanding of the purpose of the added route, I would say:

  • Yes, I am proposing to remove the route and add the automation for the workaround. Unless the route is required.

I do not know which route should be removed. Can you clarify ?

#7288 did not add any route from my understanding.

the routes to internal sites via private network is expected, from many years ago.

weizhouapache avatar Jun 13 '25 17:06 weizhouapache

@weizhouapache , you are probably right about when the route was added. I might have made the assumption based on added line 32 plus my limited understanding of how things work under the rood:

Image

What I can say is that the route is created and that I couldn't find out the purpose of it yet.

daviftorres avatar Jun 13 '25 17:06 daviftorres

Moreover,

In our current setup, we rotate the edge certificate without restarting the SSVM, CPVM, or Management service to avoid downtime.

Since NGINX doesn’t validate backend certificates by default (though it can), clients aren’t affected when a new certificate is applied (aside from possible cert caching or possible re-login, which haven’t been reported.

Ideally, SysVMs should be updated using a RollingUpdate strategy (starting a new one before stopping the old) to avoid the ~1 minute of downtime across all zones.

For Management, a multi-instance setup with a reverse proxy makes staggered updates easy.

In short, this proposed feature would bring more benefits than expected.

daviftorres avatar Jun 30 '25 14:06 daviftorres

As a workaround the access control of who can "copy" can be done on the edge (Reverse Proxy), not inside the SSVM.

    location /copy {
        allow 100.100.100.100;        # Satellite Zone A
        allow 200.200.200.200;        # Satellite Zone B
        # add more as needed
        deny all;
    }

daviftorres avatar Sep 04 '25 14:09 daviftorres

This issue is being discussed at https://github.com/apache/cloudstack/discussions/11562#discussioncomment-14305414

daviftorres avatar Sep 04 '25 14:09 daviftorres