Nginx反向 Proxy後防盜鏈設定

來源:互聯網
上載者:User

分享一下設定心得,nginx反向 Proxy後,如果再用feresers來設定防盜鏈,所有檔案的定向都會發生錯誤,經過慢慢地測試,發現只需要If判斷通過的情況下手動再設定一次proxy_pass,等同於這種情況下location /{}配置節並沒有生效,

樣本配置如下

server {   listen   80;   server_name  test.luoo.net;  #        access_log  /home/www/logs/luoo.net_access.log;  location ~ .*\.(mp3|ogg|aac)$ {     valid_referers none blocked bus.fm *.bus.fm luoo.net *.luoo.net ;     if ($invalid_referer) {     return 403;      }      proxy_pass http://219.151.*.*:8090;  }   location / {      proxy_pass http://219.151.*.*:8090;   }}

以上,網站發布在該伺服器8090連接埠,用nginx80連接埠反向 Proxy,同時簡單判斷一下請求來源(validreferes)和請求目標(mp3/ogg等),不符合規則的就返了一個403錯誤。

到此為止,網上的教程都是教你這麼設的,現在既然在設定反向 Proxy,那麼就在if後加多一句proxy_pass就可以了,同時location /{}一節就不起作用了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.