- Steps to reproduce the issue: Created a sample ABP project Auth server : https://localhost:44339 Host Server : Https://localhost:44342 WebServer : Https://localhost:44378
Goal is to make : Hostserver: Https://localhost:44378/api AuthServer: Https://localhost:44378/auth webServer: Https://localhost:44378
I tried reverse proxy but it is not working.
2 Answer(s)
-
0
To achieve your goal of exposing multiple ABP services (Host, Auth, Web) under a single domain and port using a reverse proxy, you need to ensure that:
- Each backend service is configured to work behind a reverse proxy.
- Path-based routing is set up in your reverse proxy (e.g., IIS, Nginx, or YARP).
- Forwarded headers are correctly handled in your ABP applications.
Key Steps
1. Configure Forwarded Headers Middleware
In each ABP application's
Startup.cs
(orProgram.cs
for .NET 6+), add the Forwarded Headers Middleware at the top of the middleware pipeline:app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto });
This ensures the application correctly interprets the original request's scheme and host.
2. Reverse Proxy Path Mapping
Configure your reverse proxy to map paths as follows:
/api
→ Host Server (https://localhost:44342
)/auth
→ Auth Server (https://localhost:44339
)/
→ Web Server (https://localhost:44378
)
For example, in IIS, you can use URL Rewrite rules or in YARP (Yet Another Reverse Proxy) you can define routes in
appsettings.json
.3. Update ABP Configuration
- Set
App:SelfUrl
,AuthServer:Authority
, andRemoteServices:Default:BaseUrl
in each app'sappsettings.json
to use the public-facing URL (https://localhost:44378
). - Ensure CORS and redirect URIs are set to the single domain.
4. Test and Debug
- Make sure all static files, cookies, and authentication flows work as expected.
- If you encounter issues with authentication or redirects, double-check the forwarded headers and public URLs.
Reference
This approach is required for correct operation behind a reverse proxy, especially for authentication and URL generation.
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0