NGINX / Openshift-位置块重定向到错误的端口

时间:2018-09-05 16:40:16

标签: redirect nginx openshift

我在Openshift的Docker容器内的端口8443上运行了NGINX。我还定义了Openshift路由,该路由将流量从端口443转发到容器的8443

这很好,直到我尝试访问一个位置块而该URL上没有结尾/为止。例如,当我转到:

https://test.example.com/example

JS网络日志显示NGINX试图将我重定向到错误的端口(8443):

https://test.example.com:8443/example/

由于唯一公开公开的端口是443,所以此操作失败。 FWIW,添加尾部斜杠(https://test.example.com/example/)时效果很好

有没有办法让NGINX在重定向期间不使用其内部端口,而是坚持使用客户端使用的端口?这是我的位置限制示例:

location /example {
  proxy_pass https://example.apps.svc.cluster.local:8443;
}

1 个答案:

答案 0 :(得分:0)

我最终在HttpCoreModule文档中找到了答案。必须在位置块中包含func getAllTitlesDurations(date: Date) -> (titles: [String], duration: [Double]) { // date extension to get first and last moment of date let dateDayStart = date.startOfDay let dateDayNext = date.endOfDay var durations : [Double] = [] var titles : [String] = [] // core data fetch, predicate to today guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return ([],[]) } let context = appDelegate.persistentContainer.viewContext let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: entityNames.Record.rawValue) fetchRequest.predicate = NSPredicate(format:"(endDate >= %@) AND (endDate < %@)", dateDayStart as CVarArg, dateDayNext as CVarArg) do { let records = try context.fetch(fetchRequest) as! [Record] // create unique titles titles = Array(Set(records.map{$0.title!})) for m in titles { durations.append(records .filter{$0.title == m} .reduce(0){$0 + $1.duration}) } //MARK : Check outputs print (durations) print(titles) } catch let error as NSError { print("Could not fetch. \(error), \(error.userInfo)") return ([],[]) } return (titles, durations) } 。例如:

port_in_redirect off;