I want to create ABP application, expecially ABP module solution. I want to find out the precise package version that abp depends on.
only with Enter? the ABP framework will splict my multiple lines by Enter to get multiple URLS?
How to setup multi urls? I must add my internet address to below picture.
I think my error is caused by some configuration. I must configure my Blazor application to work with Nginx reverse proxy.
tow years ago, I use below code to let my blazor application work with Nginx reverse proxy.
#if RELEASE
//这里的作用是:跳转到微信的登入页面时,原始网址是https而不是http
app.Use(async (context, next) =>
{
context.Request.Scheme = "https";
await next.Invoke();
});
#endif
app.UseAbpRequestLocalization();
It always work very well. Now I follow your link and changed above code as below.
#if RELEASE
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
#endif
app.UseAbpRequestLocalization();
Full code is just like this:
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
#if RELEASE
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
#endif
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{
app.UseErrorPage();
app.UseHsts();
app.UseHttpsRedirection();
}
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseAbpSecurityHeaders();
app.UseCors();
app.UseAuthentication();
app.UseAbpOpenIddictValidation();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
After I do above changed. I got error while access OpenDict application.
error "invalid_request"
error_description "This server only accepts HTTPS requests."
error_uri "https://documentation.openiddict.com/errors/ID2083"
But I still get error in Blazor application.
[12:33:13 WRN] Could not find IdentityClientConfiguration for Gitlab. Either define a configuration for Gitlab or set a default configuration.
[12:33:13 INF] Start processing HTTP request GET https://erp2api.abc.cn:222/api/gitlab/project/id?repositoryId=85&api-version=1.0
[12:33:13 INF] Sending HTTP request GET https://erp2api.abc.cn:222/api/gitlab/project/id?repositoryId=85&api-version=1.0
[12:33:14 INF] Received HTTP response headers after 168.3319ms - 200
[12:33:14 INF] End processing HTTP request after 168.6008ms - 200
I created a test controller as below.
[HttpGet]
[Route("test")]
public IActionResult Get()
{
// 获取所有请求头
var headers = HttpContext.Request.Headers;
StringBuilder headerInfo = new StringBuilder();
foreach (var header in headers)
{
headerInfo.AppendLine($"Header: {header.Key} = {string.Join(", ", header.Value)}");
}
// 获取所有Cookies
var cookies = Request.Cookies;
foreach (var cookie in cookies)
{
headerInfo.AppendLine($"Cookie: {cookie.Key} = {cookie.Value}");
}
return Content(headerInfo.ToString(), "text/plain");
}
Because I deploy http api as a site. I access my test controller and get below output in browser. It means that the Nginx work well with Cookie: .AspNetCore.Antiforgery.BUGx2_C-Cws
Header: Accept = text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Header: Connection = close
Header: Host = ###.###.cn:###
Header: User-Agent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:126.0) Gecko/20100101 Firefox/126.0
Header: Accept-Encoding = gzip, deflate, br, zstd
Header: Accept-Language = zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Header: Cookie = rl_user_id=%22RudderEncrypt%3AU2FsdGVkX18rU95B0qvJbBYLEm4rS3x0H3iFnH%2B5ltjXlQ180T0yRiw4oBfoAETl%22; .AspNetCore.Antiforgery.BUGx2_C-Cws=CfDJ8Aanjc0JmFlIqopqBiRGj8AQdnzUs-h3sav43a81Yt8byDG32lCcJKyM4MCle3XgT_Dp_AJ3WH7L4QL3urlaQoAXn0ZaPVG4j7gPb8xFfAP4kK746Qb5S30g84d4UTv1_MZxIrzkJCpknqmY0KsnaWg; XSRF-TOKEN=CfDJ8Aanjc0JmFlIqopqBiRGj8A8lww8ceglibBW-nSy2hH2ojj_p98hxY2jyLvl3iUyPk6oJX1pUbWaapDHCId9kFP2Uotvf5VM1SDtapecsOuB9vtCSrYLr4nHMsLN0lfnI5QDNTpb2AcjNLora1jFMFE
Header: Upgrade-Insecure-Requests = 1
Header: X-Forwarded-For = 61.174.128.225
Header: X-Forwarded-Proto = https
Header: sec-fetch-dest = document
Header: sec-fetch-mode = navigate
Header: sec-fetch-site = none
Header: sec-fetch-user = ?1
Header: priority = u=1
Cookie: rl_user_id = "RudderEncrypt:U2FsdGVkX18rU95B0qvJbBYLEm4rS3x0H3iFnH+5ltjXlQ180T0yRiw4oBfoAETl"
Cookie: .AspNetCore.Antiforgery.BUGx2_C-Cws = CfDJ8Aanjc0JmFlIqopqBiRGj8AQdnzUs-h3sav43a81Yt8byDG32lCcJKyM4MCle3XgT_Dp_AJ3WH7L4QL3urlaQoAXn0ZaPVG4j7gPb8xFfAP4kK746Qb5S30g84d4UTv1_MZxIrzkJCpknqmY0KsnaWg
Cookie: XSRF-TOKEN = CfDJ8Aanjc0JmFlIqopqBiRGj8A8lww8ceglibBW-nSy2hH2ojj_p98hxY2jyLvl3iUyPk6oJX1pUbWaapDHCId9kFP2Uotvf5VM1SDtapecsOuB9vtCSrYLr4nHMsLN0lfnI5QDNTpb2AcjNLora1jFMFE
May I change the name of cookie for Antiforgery?
Perhaps the name of cookie contains special character. So nginx block it?
I am very practices with HTTPS reverse proxy. And I added below lines to xxxModule.cs to supprot HTTPS.
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
#if RELEASE
//这里的作用是:跳转到微信的登入页面时,原始网址是https而不是http
app.Use(async (context, next) =>
{
context.Request.Scheme = "https";
await next.Invoke();
});
#endif
app.UseAbpRequestLocalization();
if (!env.IsDevelopment())
{
app.UseErrorPage();
}
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseAbpSecurityHeaders();
app.UseCors();
app.UseAuthentication();
app.UseAbpOpenIddictValidation();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseDynamicClaims();
app.UseAuthorization();
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
#