最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2023年11月06日 09:56:17   作者:緣友一世  
本文主要介紹了nginx重定向解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

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

訪(fǎng)問(wèn)日志文件

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)容

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;
    }
	
}
}

問(wèn)題分析

  • 根據(jù)提供的訪(fǎng)問(wèn)日志和nginx.conf配置文件分析,是循環(huán)重定向的問(wèn)題。
  • 配置中,location / 塊使用了 try_files $uri $uri/ /index.html; 會(huì)導(dǎo)致導(dǎo)致在嘗試訪(fǎng)問(wèn)根目錄時(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)的文章就介紹到這了,更多相關(guān)nginx重定向 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

最新評(píng)論

攀枝花市| 南安市| 福州市| 红桥区| 区。| 沂水县| 陈巴尔虎旗| 南京市| 大方县| 绥棱县| 太仓市| 孝感市| 宁武县| 扶余县| 克山县| 铁力市| 长海县| 砀山县| 遂昌县| 本溪市| 无极县| 伊宁县| 亚东县| 乌鲁木齐县| 肃北| 东台市| 偏关县| 彭水| 双城市| 怀安县| 绍兴市| 山丹县| 麻阳| 福海县| 壤塘县| 东安县| 响水县| 柞水县| 旬阳县| 米林县| 商城县|