我想在同一个 nginx 配置中的同一端口(443)上处理 2 个服务器名,例如“web1.example.com”和“web2.example.com”,其中第一个应该是本地服务器http,第二个需要转发到外部上游而不终止 SSL 连接。
我该如何配置这个?
细节:
我可以使用 nginx 查看第一条 SSL 消息 (CLientHello) 并使用它来代理/转发整个连接,而无需终止 SSL。这甚至可以查看 SNI 并根据其中的服务器名称选择不同的上游。这使用ngx_stream_ssl_preread_module和proxy_pass。ssl_preread on配置是这样的:
stream {
upstream web1 {
server 10.0.0.1:443;
}
upstream web2 {
server 10.0.0.2:443;
}
map $ssl_preread_server_name $upstream {
web1.example.com web1;
web1-alias.example.com web1;
web2.example.com web2;
}
server {
listen 443;
resolver 1.1.1.1;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass $upstream;
ssl_preread on;
}
}
Run Code Online (Sandbox Code Playgroud)
这是在streamnginx 的 config 部分配置的。
但我也可以在 nginx 的配置部分配置本地 http 服务器 …
绑定到一个本身包含在属性中的对象的属性似乎是在典型的应用程序中做了很多事情,在JavaFX中有比在下面做的更好的方法吗?
更多细节需要解释:我想在JavaFX 2.2中制作GUI,用于管理大量项目.我已经创建了一个小例子来测试所有项目,其中项目是人.这组人员以自定义方式显示(不是列表或树,但我认为这不重要),我可以选择一个.
在侧面板中,我可以编辑当前选定的人.更新会立即显示在一组人员中,当我选择其他人时,更新编辑面板.
JavaFX的双向绑定似乎非常适合此目的.我目前有这个用于fx:"人物编辑"窗格的控制器:
public class PersonEditor implements ChangeListener<Person> {
@FXML private TextField nameField;
@FXML private TextField ageField;
@FXML private TextField heightField;
public void setSelection(ObjectProperty<Person> selectedPersonProperty) {
selectedPersonProperty.addListener(this);
}
@Override
public void changed(ObservableValue<? extends Person> observable, Person oldVal, Person newVal) {
if (oldVal != null) {
nameField.textProperty().unbindBidirectional(oldVal.nameProperty());
ageField.textProperty().unbindBidirectional(oldVal.ageProperty());
heightField.textProperty().unbindBidirectional(oldVal.heightProperty());
}
if (newVal != null) {
nameField.textProperty().bindBidirectional(newVal.nameProperty());
ageField.textProperty().bindBidirectional(newVal.ageProperty());
heightField.textProperty().bindBidirectional(newVal.heightProperty());
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更好的方法,也许JavaFX中的东西可以绑定到可以改变的对象的属性?我不喜欢我必须手动取消绑定所有属性的事实,感觉就像重复的代码.或者这是否像在JavaFx中一样简单?
我有多个工作线程和一个JavaFX GUI,它报告这些线程中发生的事情.
线程之间共享了大量数据,需要对其进行可视化.所以我使用ObservableList和Property来能够轻松地在JavaFX中显示数据.
我做了一个小示例应用程序来显示类似于我的应用程序中发生的事情.它有2个列表,工作线程将数据从一个列表移动到另一个列表.状态字符串保持最新.完整的示例代码可以在http://codetidy.com/6569/找到 (此代码将崩溃,请参阅后面的内容)
以下是共享的ObservableList和属性:
private ObservableList<String> newItems;
private ObservableList<String> readyItems;
private StringProperty status;
Run Code Online (Sandbox Code Playgroud)
以下是它们在JavaFX中的使用方式:
listViewA.setItems(processor.getNewItems());
listViewB.setItems(processor.getReadyItems());
statusLabel.textProperty().bind(processor.getStatus());
Run Code Online (Sandbox Code Playgroud)
工作线程更新这些列表和属性,但当然,它需要在JavaFX线程上执行此操作,这就是事情变得丑陋的地方.如果我不必在JavaFX线程上更新,这将是代码:
Runnable newItemAdder = new Runnable() {
@Override
public void run() {
while(true) {
synchronized (newItems) {
String newItem = checkForNewItem(); //slow
if (newItem != null) {
newItems.add(newItem);
newItems.notify();
}
if (newItems.size() >= 5)
status.set("Overload");
else
status.set("OK");
}
synchronized (readyItems) {
if (readyItems.size() > 10)
readyItems.remove(0);
}
try { Thread.sleep(200); } catch (InterruptedException e) { return; }
}
} …Run Code Online (Sandbox Code Playgroud) 我在我的scala代码中发现了一个错误,这让我很困惑.以下是问题的简化版本.
在抽象类的构造函数,我想查一些关于断言抽象方法.因此,当一个子类的对象制成,这些断言进行检查,看是否所有的被实现,因为它应该.
当子类使用"val"实现抽象方法时会出错:
Scala代码:
abstract class A {
def aval : String
assert(aval != null, "aval == null")
assert(aval == "B", "aval: "+aval)
}
class B extends A {
def aval = "B"
}
class C extends A {
val aval = "B"
}
object VariousScalaTests {
def main(args : Array[String]) : Unit = {
val b = new B
val c = new C
}
}
Run Code Online (Sandbox Code Playgroud)
Scala错误:
Exception in thread "main" java.lang.AssertionError: assertion failed: aval == null
at scala.Predef$.assert(Predef.scala:92) …Run Code Online (Sandbox Code Playgroud)