您好,登錄后才能下訂單哦!
使用Nginx怎么實(shí)現(xiàn)一個(gè)非套路鏡像站?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
方案一
做了如下配置:
1 2 3 4 5 6 7 8 |
|
瀏覽了下,都 ok,但是有幾點(diǎn)不太好
如果以后我發(fā)現(xiàn)類似的書很好,都要增加一個(gè) nginx 配置。
如果原始網(wǎng)站完全無(wú)法訪問(wèn)了,我這邊也掛了,不能緩存到我本地服務(wù)器。
我想修改網(wǎng)頁(yè)內(nèi)容也不太好操作,比如我想加上原作者的版權(quán)和原始訪問(wèn)地址說(shuō)明等。
完全采集過(guò)來(lái),我也懶得寫腳本去跑,最終走上了下面這段踩坑路。
嘗試改進(jìn)
1 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
又遇到了一個(gè)問(wèn)題,當(dāng)我訪問(wèn) https://mengkang.net/book-c/styles.css 則無(wú)法 rewrite 匹配到了。
原因是 nginx 優(yōu)先匹配了
1 2 3 4 |
|
方案二
添加一條
?
1 2 3 4 |
|
location ^~ 不支持正則的,所以沒(méi)法用
采坑小記
如果是使用的 location ~ /book-.*/ ,根據(jù)正則就是貪婪模式,那么
https://cache.yisu.com/upload/information/20210309/289/47891.jpg
匹配到的就是 /book-c/images/ ,也就是說(shuō)rewrite里面的 $1 就是 c/images ,這樣和我們的預(yù)期相悖的。
故障:無(wú)法匹配到 css 文件
?
1 2 3 4 5 6 7 8 9 |
|
所有內(nèi)容的輸出默認(rèn)都是 text/html ,那么也就是我需要對(duì)文件的后綴判斷咯。 感覺(jué)自己給自己挖坑,不如直接采集得了
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
看完上述內(nèi)容,你們掌握使用Nginx怎么實(shí)現(xiàn)一個(gè)非套路鏡像站的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
原文鏈接:http://mengkang.net/1152.html
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。