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

nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404問題

 更新時(shí)間:2024年06月20日 08:49:10   作者:飄零未歸人  
這篇文章主要介紹了nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

nginx的location配置導(dǎo)致網(wǎng)關(guān)返回404

再項(xiàng)目中使用nginx轉(zhuǎn)發(fā)到網(wǎng)關(guān)時(shí),發(fā)現(xiàn)返回了404.

{

    "timestamp": "2023-11-01T02:12:48.788+00:00",

    "path": "http://core-manage-web/core/core-manage/servers/findServers",

    "status": 404,

    "error": "Not Found",

    "message": null,

    "requestId": "642b125b"

}

從這個(gè)返回來看,應(yīng)該是網(wǎng)關(guān)返回的信息。因?yàn)槿绻莕ginx返回404的話,應(yīng)該是返回的404.html才對(duì)。

所以看看出是網(wǎng)關(guān)找不到轉(zhuǎn)發(fā)的路徑。 從  "path": "//core-manage-web/core/core-manage/servers/findServers",看出我們的接口經(jīng)過nginx轉(zhuǎn)發(fā)之后,居然只有兩個(gè)//。正常應(yīng)該只有一個(gè)才對(duì)。

再看一下location配置:

location /core {
    proxy_pass http://gateway-upstream/;
}

由于第一次使用使用nginx,所以對(duì)于這些配置還不是很了解。這上面的的  “location /core”標(biāo)識(shí)路徑前綴匹配。 而我的 “http://core-gateway-upstream/”是以“/”結(jié)尾,這表示會(huì)將 location的匹配路徑(/core)替換掉在轉(zhuǎn)發(fā)。

gateway-upstream配置如下

upstream gateway-upstream {
    server 192.168.111.1:10006;
}

所以如果我是用 http:localhost:8080/core/login/xxxxx訪問,則經(jīng)過nginx轉(zhuǎn)發(fā)之后會(huì)變成192.168.111.1:10006//login/xxxxx

所以需要將 location /core改成 location /core/。即可:

location /core/ {
    proxy_pass http://gateway-upstream/;
}

nginx配置多個(gè)location訪問報(bào)404

解決方法

在自己配置的location中不要使用root配置文件目錄,替換為alias即可

完整配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            autoindex on;             #開啟索引功能
            autoindex_exact_size off; # 關(guān)閉計(jì)算文件確切大?。▎挝籦ytes),只顯示大概大?。▎挝籯b、mb、gb)
            autoindex_localtime on;   # 顯示本機(jī)時(shí)間而非 GMT 時(shí)間
            charset utf-8; # 避免中文亂碼
            root   file;
            #index  index.html index.htm;
        }
        
        location /file {
	    alias   html;
            index  index.html index.htm;
	}
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • nginx proxy_set_header的具體實(shí)現(xiàn)

    nginx proxy_set_header的具體實(shí)現(xiàn)

    proxy_set_header?是 Nginx 配置中的一個(gè)重要指令,本文主要介紹了nginx proxy_set_header的具體實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-07-07
  • web部署到nginx以后js,css等靜態(tài)文件加載不正常的解決過程

    web部署到nginx以后js,css等靜態(tài)文件加載不正常的解決過程

    在Ubuntu中配置Web頁面時(shí),JS和CSS文件雖可獲取但加載失敗,可能因路徑錯(cuò)誤、服務(wù)器配置不當(dāng)、權(quán)限限制或緩存問題導(dǎo)致頁面布局異常,需檢查文件路徑、服務(wù)器設(shè)置、MIME類型及瀏覽器控制臺(tái)錯(cuò)誤信息以排查原因
    2025-09-09
  • nginx設(shè)置超時(shí)時(shí)間的問題及解決方案

    nginx設(shè)置超時(shí)時(shí)間的問題及解決方案

    程序在處理大量數(shù)據(jù),接口超過1分鐘(默認(rèn)的)未返回?cái)?shù)據(jù),導(dǎo)致等待超時(shí),出現(xiàn)這種情況,我們可以先優(yōu)化程序,縮短執(zhí)行時(shí)間,可以調(diào)大nginx超時(shí)限制的參數(shù),使程序可以正常執(zhí)行,本文介紹nginx設(shè)置超時(shí)時(shí)間及504 Gateway Time-out的問題解決方案,一起看看吧
    2024-02-02
  • Nginx?禁止直接訪問目錄或文件的操作方法

    Nginx?禁止直接訪問目錄或文件的操作方法

    Nginx?默認(rèn)是不允許列出整個(gè)目錄的,那么需要這樣的功能怎么操作呢,下面小編給大家介紹下Nginx?禁止直接訪問目錄或文件的方法,需要的朋友可以參考下
    2022-10-10
  • Nginx配置后請(qǐng)求報(bào)404的幾種問題解決方法

    Nginx配置后請(qǐng)求報(bào)404的幾種問題解決方法

    本文主要介紹了Nginx配置后請(qǐng)求報(bào)404的兩種常見問題及其解決方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2025-02-02
  • nginx配置相關(guān)介紹

    nginx配置相關(guān)介紹

    本文為大家介紹一下nginx配置的相關(guān)介紹,供大家參考
    2013-02-02
  • nginx proxy_pass 路徑拼接的具體實(shí)現(xiàn)

    nginx proxy_pass 路徑拼接的具體實(shí)現(xiàn)

    本文主要介紹了nginx proxy_pass 路徑拼接的具體實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2026-05-05
  • windows下RunHiddenConsole 啟動(dòng) nginx與php(RunHiddenConsole下載)

    windows下RunHiddenConsole 啟動(dòng) nginx與php(RunHiddenConsole下載)

    這篇文章主要介紹了RunHiddenConsole 啟動(dòng) nginx與php的相關(guān)資料,希望通過本文能幫助到大家,讓大家學(xué)會(huì)使用RunHiddenConsole,需要的朋友可以參考下
    2017-10-10
  • nginx 配置服務(wù)啟動(dòng)的教程詳解

    nginx 配置服務(wù)啟動(dòng)的教程詳解

    本文給大家詳細(xì)介紹了nginx 配置服務(wù)啟動(dòng)的相關(guān)知識(shí),非常不錯(cuò),具有一定的參考借鑒價(jià)值,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05
  • Nginx進(jìn)程管理和重載原理詳解

    Nginx進(jìn)程管理和重載原理詳解

    這篇文章主要給大家介紹了關(guān)于Nginx進(jìn)程管理和重載原理的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04

最新評(píng)論

桑日县| 双桥区| 五家渠市| 房山区| 建始县| 富民县| 黑山县| 武夷山市| 星座| 阿尔山市| 武宁县| 阳谷县| 高安市| 湛江市| 通辽市| 新河县| 板桥市| 龙南县| 靖安县| 睢宁县| 奉贤区| 宜春市| 鄂尔多斯市| 甘孜| 苏尼特左旗| 晋城| 收藏| 湟中县| 洛扎县| 松滋市| 宁波市| 鄯善县| 比如县| 仁化县| 河北省| 贵州省| 宜兴市| 淳化县| 临桂县| 克东县| 尼勒克县|