我在nginx后面安装了api。我只想我的前端域例如https://myfrontend.com访问的api我试过使用检查$host,但这是相同的server_name
https://myfrontend.com
$host
server_name
/api { # how to do i allow only myfrontend.com to access it? proxy_pass http://127.0.0.1; }
帮助赞赏!
piv4azn71#
为我解决。
location / { if ($http_origin != "https://myfrontend.com") { return 403; } proxy_pass http://127.0.0.1:3000; }
1条答案
按热度按时间piv4azn71#
为我解决。