ฉันใช้ nginx เพื่อให้บริการเว็บไซต์ของฉัน ฉันต้องการปิดกั้นคำขอทั้งหมดที่มีส่วนหัว HTTP "โฮสต์" ที่ไม่ตรงกับโดเมนของเว็บไซต์ของฉัน
เพื่อให้เป็นรูปธรรมมากขึ้น nginx.conf ของฉันมีบล็อกเซิร์ฟเวอร์ทั้งสองนี้:
server {
# Redirect from the old domain to the new domain; also redirect
# from www.newdomain.com to newdomain.com without the "www"
server_name www.olddomain.com olddomain.com www.newdomain.com;
listen 80;
return 301 $scheme://newdomain.com$request_uri;
}
server {
server_name newdomain.com localhost;
listen 80;
# Actual configuration goes here...
}
ฉันต้องการบล็อก (เช่น“ ส่งคืน” รหัสสถานะ 444) การรับส่งข้อมูลใด ๆ ที่โฮสต์ไม่ได้เป็น www.olddomain.com, olddomain.com, www.newdomain.com หรือ newdomain.com ฉันจะทำสิ่งนี้ได้อย่างไร