Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adam 2 posts 92 karma points
    Sep 10, 2024 @ 12:49
    Adam
    0

    Umbraco 13 Generates HTTP URLs Instead of HTTPS on Kubernetes Deployment

    Context:

    • Umbraco Version: 13
    • Environment: Deployed on Kubernetes
    • Ingress Controller: Nginx
    • Reverse Proxy: Yes, using HTTPS termination at the ingress level
    • Kubernetes Cluster Configuration:
      • HTTPS works fine when accessing the site.
      • Umbraco correctly redirects all requests to HTTPS.
      • Issue: Umbraco-generated URLs (e.g., via Model.Url(mode: UrlMode.Absolute)) are still being returned with http:// instead of https://.

    Actions Taken So Far:

    1. Configured UmbracoApplicationUrl: Added the following setting in appsettings.json to explicitly set the base URL:

      json { "Umbraco": { "CMS": { "WebRouting": { "UmbracoApplicationUrl": "https://mydomain.com" } } } } This did not resolve the issue.

    2. Nginx Ingress Annotations: Ensured that the ingress resource has the necessary annotations: yaml annotations: nginx.ingress.kubernetes.io/force-ssl-redirect: "true" nginx.ingress.kubernetes.io/x-forwarded-proto: "https" The ingress correctly handles SSL and redirects all traffic to HTTPS.

    Expected Behavior:

    • All Umbraco-generated URLs (e.g., via Model.Url(mode: UrlMode.Absolute)) should use the https:// scheme when accessed via HTTPS.

    Actual Behavior:

    • URLs generated by Umbraco are still using the http:// scheme, even though the site is running over HTTPS, and all requests are correctly redirected to HTTPS.

    Additional Information:

    • Platform: Kubernetes cluster with Nginx ingress (please replace with your ingress if different).
    • SSL Termination: Handled at the ingress level with valid TLS certificates.
    • Ingress Configuration:
      • Using a standard Kubernetes ingress resource with HTTPS enforced via annotations.

    Please advise on how to correctly configure Umbraco to generate HTTPS URLs in this environment.

  • Adam 2 posts 92 karma points
    Sep 11, 2024 @ 08:02
    Adam
    100

    The issue have been fixed by adding app.UseForwardedHeaders(); app.UseHttpsRedirection(); to the top of the function Configure(IApplicationBuilder app, IWebHostEnvironment env)

    And adding below code: public void ConfigureServices(IServiceCollection services){ services.Configure<ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; options.KnownNetworks.Clear(); options.KnownProxies.Clear(); });

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies