国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

nginx重定向問題解決(rewrite or internal redirection cycle)

這篇具有很好參考價(jià)值的文章主要介紹了nginx重定向問題解決(rewrite or internal redirection cycle)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

錯(cuò)誤日志和配置文件

訪問日志文件

2023/10/15 07:13:48 [error] 30#30: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 123.55.159.97, server: server_name, request: "GET / HTTP/1.1", host: "xxx.xxx.xxx.xxx"
123.55.159.97 - - [15/Oct/2023:07:13:48 +0000] "GET / HTTP/1.1" 500 579 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46"
123.55.159.97 - - [15/Oct/2023:07:13:48 +0000] "GET /favicon.ico HTTP/1.1" 500 579 "http:///" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46"
2023/10/15 07:13:48 [error] 30#30: *2 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 123.55.159.97, server: server_name, request: "GET /favicon.ico HTTP/1.1", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/"

nginx.conf配置文件內(nèi)容文章來源地址http://www.zghlxwxcb.cn/news/detail-755760.html

events {
	worker_connections  1024;
}

http {
include       mime.types;
default_type  application/octet-stream;
sendfile        on;
keepalive_timeout  65;

client_max_body_size     50m;
client_body_buffer_size  10m; 
client_header_timeout    1m;
client_body_timeout      1m;

gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_comp_level  4;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
server {
listen       80;
server_name  my_server_name;

    location / {		
        root   /usr/local/xxx_vue;
        index  index.html index.htm; 
        try_files $uri $uri/ /index.html;	
    }
		
location ^~ /api/ {		
        proxy_pass http://xxx.xxx.xxx.xxx:8080/;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;						
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
	
}
}

問題分析

  • 根據(jù)提供的訪問日志和nginx.conf配置文件分析,是循環(huán)重定向的問題。
  • 配置中,location / 塊使用了 try_files $uri $uri/ /index.html; 會(huì)導(dǎo)致導(dǎo)致在嘗試訪問根目錄時(shí)發(fā)生重定向循環(huán)。
  • 修改:添加一個(gè)新的location=/index塊,直接提供 /index.html 而不進(jìn)行重定向。
server {
    listen 80;
    server_name my_server_name;

    location / {
        root /usr/local/xxx_vue;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

    location = /index.html {
        root /usr/local/xxx_vue;
    }

    location ^~ /api/ {
        proxy_pass http://xxx.xxx.xxx.xxx:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
  • 使用以下命令重新加載Nginx,即可生效
    sudo nginx -s reload
    

到了這里,關(guān)于nginx重定向問題解決(rewrite or internal redirection cycle)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 重定向(Redirect)

    重定向(Redirect)

    重定向(Redirect)就是通過各種方法將各種網(wǎng)絡(luò)請(qǐng)求重新定個(gè)方向轉(zhuǎn)到其它位置(如:網(wǎng)頁重定向、域名的重定向、路由選擇的變化也是對(duì)數(shù)據(jù)報(bào)文經(jīng)由路徑的一種重定向)。 我們?cè)诰W(wǎng)站建設(shè)中,時(shí)常會(huì)遇到需要網(wǎng)頁重定向的情況: 1.網(wǎng)站調(diào)整(如改變網(wǎng)頁目錄結(jié)構(gòu)); 2.網(wǎng)頁

    2023年04月08日
    瀏覽(25)
  • location模塊與rewrite重定向

    目錄 location 常用的nginx正則表達(dá)式 URI location分類 location常用的匹配規(guī)則 location優(yōu)先級(jí) location實(shí)例說明 優(yōu)先級(jí)總結(jié) 在實(shí)際網(wǎng)站中使用的匹配規(guī)則至少有三個(gè)匹配規(guī)則 rewrite rewrite執(zhí)行順序 nginx的內(nèi)置變量 ^:匹配輸入字符串的起始位置 $:匹配輸入字符串的結(jié)束位置 *:匹配前面

    2024年02月13日
    瀏覽(17)
  • 【問題】‘git‘ is not recognized as an internal or external command, operable program or batch file.

    【問題】‘git‘ is not recognized as an internal or external command, operable program or batch file.

    如果未安裝\\\"git\\\",則需要安裝git,安裝時(shí)選擇\\\"從Windows命令提示符使用Git\\\"選項(xiàng). 如果安裝了\\\"git\\\",但仍然會(huì)出現(xiàn)\\\"git未被識(shí)別為內(nèi)部或外部命令\\\"錯(cuò)誤,則需要將PATH變量設(shè)置為指向git可執(zhí)行文件.為此,請(qǐng)按照以下步驟操作: 打開我的電腦,右鍵單擊并選擇屬性 單擊\\\"高級(jí)系統(tǒng)設(shè)置\\\" 單擊\\\"環(huán)

    2024年01月16日
    瀏覽(19)
  • Nginx處理302重定向端口丟失問題

    業(yè)務(wù)部署于Linux虛擬機(jī)中,域名解析到公網(wǎng)ip,公網(wǎng)ip的非標(biāo)準(zhǔn)端口映射虛機(jī)的標(biāo)準(zhǔn)端口。由于種種原因無法使用公網(wǎng)標(biāo)準(zhǔn)端口(80、443),只能使用非標(biāo)準(zhǔn)端口,公網(wǎng)端口8050到虛機(jī)80、公網(wǎng)端口8051到虛機(jī)443。 虛機(jī)內(nèi)部通過Nginx當(dāng)做靜態(tài)資源服務(wù)器,監(jiān)聽80、443端口,而在虛機(jī)

    2024年02月16日
    瀏覽(19)
  • 出現(xiàn) “‘mysql’ is not recognized as an internal or external command, operable program or batch file解決方法

    在 Windows 系統(tǒng)的 DOS 窗口通過命令行的方式登錄 MySQL,出現(xiàn) “‘mysql’ is not recognized as an internal or external command, operable program or batch file” 的提示 意味著系統(tǒng)無法識(shí)別或找不到 MySQL 的可執(zhí)行文件 。這可能是由于以下幾個(gè)原因?qū)е碌模?MySQL 未正確安裝:確保 MySQL 已正確安裝并

    2024年02月07日
    瀏覽(26)
  • Nginx將http重定向到https,一直提示重定向次數(shù)過多(已解決)

    先貼一下nginx的配置 return和rewrite都已經(jīng)試過了,都是多次重定向?qū)е聼o法進(jìn)入頁面 后續(xù)在https區(qū)域中將連接后端地址的api區(qū)域復(fù)制過來后,再加上下方代碼完美解決 #將所有HTTP請(qǐng)求通過rewrite指令重定向到HTTPS。 rewrite ^(.*)$ https://$host$1;

    2024年02月19日
    瀏覽(25)
  • Nginx Proxy Manager申請(qǐng)證書出現(xiàn)Internal Error的解決方法

    這是2.9.19的bug,退回到2.9.18就沒問題了。 附上安裝Nginx Proxy Manager中文版的docker-compose.yml文件

    2024年02月15日
    瀏覽(20)
  • 【看表情包學(xué)Linux】文件描述符 | 重定向 Redirection | dup2 函數(shù) | 緩沖區(qū)的理解 (Cache)

    【看表情包學(xué)Linux】文件描述符 | 重定向 Redirection | dup2 函數(shù) | 緩沖區(qū)的理解 (Cache)

    ?? ??? 爆笑 教程 ????《看表情包學(xué)Linux》?? ? 猛戳訂閱 ? ? ?? ?? 寫在前面: 在上一章中,我們已經(jīng)把 fd 的基本原理搞清楚了。本章我們將開始探索 fd 的應(yīng)用特征,探索 文件描述符的分配原則。講解重定向,上一章是如何使用 fflush 把內(nèi)容變出來的,介紹 dup2 函數(shù),

    2023年04月25日
    瀏覽(19)
  • nginx rewrite 用法,用rewrite去除URL中的特定參數(shù)

    日常服務(wù)中經(jīng)常會(huì)用Nginx做一層代理轉(zhuǎn)發(fā),把Nginx當(dāng)做前置機(jī) 比如,以下配置: 這里的rewrite 就是為了去除URL中的/apis,實(shí)際的后端api中是沒有這個(gè)參數(shù)的,但是為了做到在Nginx轉(zhuǎn)發(fā)請(qǐng)求,前端需要加上這個(gè)參數(shù),以便于區(qū)別 比如前端的請(qǐng)求地址是 那么實(shí)際上經(jīng)過Nginx轉(zhuǎn)發(fā)后請(qǐng)求

    2024年02月05日
    瀏覽(21)
  • Nginx服務(wù)之Rewrite

    Nginx服務(wù)之Rewrite

    目錄 一、Rewrite實(shí)際場(chǎng)景 1、Nginx跳轉(zhuǎn)需求的實(shí)現(xiàn)方式 2、rewrite放在server{},if{}, location{}段中 3、對(duì)域名或參數(shù)字符串 二、Nginx 正則表達(dá)式 三、Rewrite命令 四、Location 分類 1、分類? 2、正則匹配的常用表達(dá)式 3、location 優(yōu)先級(jí) 4、Nginx在實(shí)際網(wǎng)站中至少有三個(gè)匹配規(guī)則定義 4.1第

    2024年02月14日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包