Open Closed

Layered Solution Architecture How to Add an API Gateway #8417


User avatar
0
jonty created
  • ABP Framework version: v8.3.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server.)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:none
  • Steps to reproduce the issue: Hi, Layered Solution Architecture How to add API gateway, I want to proxy the api through the gateway in order to provide services to the outside world, currently I follow Microservice template to create my gateway project, it successfully proxies hostapi service but it is not able to get authorization for authserver what should I do with it, can it be proxied through the gateway?
"ReverseProxy": {
  "Routes": {
    "UnifiedApi": {
      "ClusterId": "HostApiServer",
      "Match": {
        "Path": "/api/{**catch-all}"
      }
    },
    "UnifiedApiSwagger": {
      "ClusterId": "HostApiServer",
      "Match": {
        "Path": "/swagger-json/HostApiServer/swagger/v1/swagger.json"
      },
      "Transforms": [
        { "PathRemovePrefix": "/swagger-json/HostApiServer" }
      ]
    },
    //// 授权服务的路由
    //"AuthServerWellKnown": {
    //  "ClusterId": "AuthServer",
    //  "Match": {
    //    "Path": "/.well-known/openid-configuration"
    //  },
    //  "Order": 1
    //},
    //"AuthServerConnectEndpoints": {
    //  "ClusterId": "AuthServer",
    //  "Match": {
    //    "Path": "/connect/{**catch-all}"
    //  },
    //  "Order": 2
    //}
  },
  "Clusters": {
    "HostApiServer": {
      "Destinations": {
        "HostApiServer": {
          "Address": "http://localhost:44362/"
        }
      }
    },
    //"AuthServer": {
    //  "Destinations": {
    //    "AuthServer": {
    //      "Address": "http://localhost:44333/"
    //    }
    //  }
    //}
  }

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I want to proxy the api through the gateway

    Gateway is like a reverse proxy server.

    Your auth server is localhost:44333, but your swagger website can't reach the auth server.

    Is localhost:44333 available?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    jonty created

    hi

    I want to proxy the api through the gateway

    Gateway is like a reverse proxy server.

    Your auth server is localhost:44333, but your swagger website can't reach the auth server.

    Is localhost:44333 available?

    I think I've solved it, I've proxied both authserver and hostapi through gateway, and now I'm left with the last one, and I don't know why I'm getting multiple inputs.

      if (IsSwaggerEnabled(configuration))
      {
          app.UseSwagger();
          app.UseAbpSwaggerUI(options => { ConfigureSwaggerUI(proxyConfig, options, configuration); });
          app.UseRewriter(CreateSwaggerRewriteOptions());
      }
          private static bool IsSwaggerEnabled(IConfiguration configuration)
        {
            return bool.Parse(configuration["Swagger:IsEnabled"] ?? "true");
        }
    
        private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration)
        {
            if (IsSwaggerEnabled(configuration))
            {
                context.Services.AddAbpSwaggerGen();
            }
        }
    
    
        private static void ConfigureSwaggerUI(
            IProxyConfig proxyConfig,
            SwaggerUIOptions options,
            IConfiguration configuration)
        {
            foreach (var cluster in proxyConfig.Clusters)
            {
                options.SwaggerEndpoint($"/swagger-json/{cluster.ClusterId}/swagger/v1/swagger.json", $"{cluster.ClusterId} API");
            }
    
            options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
            options.OAuthScopes(
                "Unified"
            );
        }
    
    

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you check the swagger html page? Maybe it loaded some javascript files multiple times.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    jonty created

    Gateway is like a reverse proxy server.

    thank u,it's worked, I'm just using the gateway as a proxy, I don't need to use swagger like microservices, previously I referenced the microservices template.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on October 05, 2026, 11:32
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.