在记录我的Web应用程序接收的HTTP标头(表现为负载均衡器+ friewall)时,我注意到我收到的X-Original-For和X-Original-Proto标头(除传统的X-Forwared-XXX标头)。
他们的目的是什么?
谢谢。
答案 0 :(得分:3)
简短答案: let paymentRequest:PKPaymentRequest = PKPaymentRequest()
let label = selectedTier == 0 ? "Tier 0 Membership" : "Tier 1 Membership"
let amount = selectedTier == 0 ? NSDecimalNumber(value: 99.0) : NSDecimalNumber(value: 189.0)
let summary1 = PKPaymentSummaryItem(label: label, amount: amount, type: .final)
let total = PKPaymentSummaryItem(label: "total", amount: amount, type: .final)
paymentRequest.paymentSummaryItems = [summary1, total]
paymentRequest.supportedNetworks = [.visa, .masterCard, .amex, .discover]
paymentRequest.merchantCapabilities = [.capability3DS, .capabilityEMV, .capabilityDebit, .capabilityCredit]
paymentRequest.currencyCode = "USD"
paymentRequest.countryCode = "US"
paymentRequest.merchantIdentifier = APPLEPAY_MERCHANTID
paymentRequest.applicationData = "ID:123456" .data(using: .utf8)
guard let authorizationVC:PKPaymentAuthorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) else{
return
}
authorizationVC.delegate = self
let delay = DispatchTime.now() + .milliseconds(300)
DispatchQueue.main.asyncAfter(deadline: delay) {
self.present(authorizationVC, animated: true, completion: nil)
}
代表在<{1}和X-Original-*
中收到的原始标头值。
长版:使用HttpContext.Connection
/ HttpContext.Request
/ Nginx
设置反向代理时,IIS
和Apache
会更改为左侧, HttpContext.Connnection
标头中的大多数值,HttpContext.Request
标头用于保存原始的X-Forwarded-*
和X-Original-*
值:
HttpContext.Connection
将另存为标题HttpContext.Request
,然后将HttpContext.Request.Scheme
更改为X-Original-Proto: ...
标题中最左侧的方案HttpContext.Request.Scheme
将保存为标题X-Forwarded-Proto: o1, o2, ...
,然后HttpContext.Request.Host
将更改为X-Original-Host: <original-host>
标题中最左侧的主机HttpContext.Request.Host
和X-Forwarded-Host: o1, o2, ...
将另存为标头HttpContext.Connection.RemoteIpAddress
,然后将此值更改为HttpContext.Connection.RemotePort
标头中最左边的IP和端口。 / li>
请参见source code of saving X-Original-For
:
OriginalForHeaderName: <original-endpoint>
请参见source code of saving X-Original-Proto
:
X-Forwarded-For: o1, o2, ...
请参见source code of saving X-Original-Host
:
requestHeaders[_options.OriginalForHeaderName] = new IPEndPoint(connection.RemoteIpAddress, connection.RemotePort).ToString();