溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Linux Centos7下如何在代理服務(wù)器(nginx通過訪問日志查看訪問到哪個(gè)真實(shí)的服務(wù)器

發(fā)布時(shí)間:2020-06-08 10:27:58 來源:網(wǎng)絡(luò) 閱讀:623 作者:wx5d4557ee5e827 欄目:系統(tǒng)運(yùn)維

在nginx子配置文件中加下面加粗字體部分

location / {
proxy_pass http://static;
proxy_redirect off;
proxy_set_header Host $host;
proxysetheader backendIP $upstreamaddr; #要代理的服務(wù)器的地址
proxysetheader backendCode $upstreamstatus; #要代理的服務(wù)器的狀態(tài)

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

在主配置文件中
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$upstream_addr" "$upstream_status"';
即可通過tailf /var/log/nginx/access.log 查看到

向AI問一下細(xì)節(jié)

免責(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)容。

AI