我想在 proxy_pass 服务器上使用 API 创建 CORS 站点。但
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 86400;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204; break;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header …Run Code Online (Sandbox Code Playgroud) 我在和接口上有 2 个静态地址(a.b.c.72/24和a.b.c.128/24)。ISP 有一个网关 。我只能在 上使用,只能在 上使用。gateway1gateway2a.b.c.1a.b.c.72gateway1a.b.c.128gateway2
如何让 abc128 工作?我想通过第二个接口路由一些本地机器。我知道一些通过 mikrotik 中不同网关进行路由的方法。在 linux 中,我可以指定dev参数进行路由。
我添加了路由表和规则,但它仍然通过 gateway2 路由。
/ip dhcp-client print
Flags: X - disabled, I - invalid
# INTERFACE USE ADD-DEFAULT-ROUTE STATUS ADDRESS
0 gateway1 yes no bound X.Y.164.72/24
1 gateway2 yes no bound X.Y.164.128/24
/ip route
add distance=51 gateway=X.Y.164.1 pref-src=X.Y.164.128 routing-mark=gate2
add distance=1 dst-address=X.Y.164.0/24 gateway=gateway2 pref-src=X.Y.164.128 routing-mark=gate2
add distance=52 gateway=X.Y.164.1 pref-src=X.Y.164.72 routing-mark=gate1
add distance=1 dst-address=X.Y.164.0/24 gateway=gateway1 …Run Code Online (Sandbox Code Playgroud)