问题描述
我有2个不同的dns记录。一个print("Enter Msg:")
def Binary_Encryption(message):
# pass 08b to format
message = ''.join(format(i,'08b') for i in bytearray(message,encoding ='utf-8'))
print(message)
Binary_Encryption(input("").replace (" ","\\"))
指向公共IP地址(即93.184.216.34),另一个domain.com
指向本地IP地址(即10.0.0.2),供同一网络上的计算机使用。
我具有以下配置,可以将本地子域proxy_pass传递给似乎有效的裸域:
local.domain.com
但是我还需要子域才能工作。 server {
listen 80;
listen [::]:443 ssl;
listen 443 ssl;
# ssl config here
server_name local.domain.com;
location / {
proxy_pass $scheme://127.0.0.1/;
set $non_local_host domain.com;
proxy_set_header Host $non_local_host;
proxy_redirect http://$non_local_host/ http://$host/;
proxy_redirect https://$non_local_host/ https://$host/;
}
}
应该代理foo.local.domain.com
,foo.domain.com
应该代理bar.baz.local.domain.com
我了解我需要复制上述服务器块。将bar.baz.domain.com
更改为server_name
,但不确定如何正确设置*.local.domain.com
指向正确的子域。
最接近的类似问题是:nginx sub-subdomain wildcard,但这是相反的方向(从未回答),而对How can i pass subdomain as proxy_pass value in nginx?的回答是,但它适用于不同的域(而不是子域),并且一些我不明白的魔术正则表达式。谢谢。
解决方法
您可以尝试以下一种方法:
map $host $non_local_host {
~^(.*\.)?local\.domain\.com "${1}domain.com";
}
server {
listen 80;
listen [::]:443 ssl;
listen 443 ssl;
# ssl config here
server_name .local.domain.com;
location / {
proxy_pass $scheme://127.0.0.1/;
proxy_set_header Host $non_local_host;
proxy_redirect http://$non_local_host/ http://$host/;
proxy_redirect https://$non_local_host/ https://$host/;
}
}
.local.domain.com
服务器名称将与local.domain.com
及其任何子域匹配。
如果您的网站使用Cookie,则可能还需要一个proxy_cookie_domain
指令:
proxy_cookie_domain $non_local_host $host;