戶反映:說自己的網站走nginx代理后,打開空白。直接IP加地址訪問是好的(http://ip:port)
故障排查:
1、打開chrome瀏覽器,訪問了下,訪問情況真是客戶描述的那樣。
2、感覺打開chrome ,開發者工具,發現部分請求URL是404,css和js的
3、找客戶要服務器登錄的賬號,檢查nginx配置文件
upstream www.test.com{ server 127.0.0.1:8080; } server { listen 80; listen 443 ssl http2; ssl_certificate /usr/local/nginx/conf/ssl/www.test.com.pem; ssl_certificate_key /usr/local/nginx/conf/ssl/www.test.com.key; server_name www.test.com; access_log /data/wwwlogs/www.test.com_nginx.log combined; index index.html index.htm index.jsp; root /data/wwwroot/www.test.com; location ~ .*\.(js|css)?$ { expires 7d; access_log off; } ? location / { proxy_pass http://www.test.com; include proxy.conf; } }
4、大家有發現上面配置有問題不?剛開始我也沒有注意,自認為配置文件是對 的。
打算檢查nginx的日志,一遍請求URL,一遍查看nginx果然還是404.(感覺疑惑),明明配置了proxy_pass http://www.test.com。
故障原因:
是因為 “location ~ .*\.(js|css)?$” 這個匹配攔截掉了,請求不能正常發往下一個“location /” ,也就不能正常抵達后端proxy_pass了。
解決方法:
第一種解決方法:是將后端的靜態文件(css 和js ),放入前置nginx 機器/data/wwwroot/www.test.com
第二種解決方法 :修改配置文件
upstream www.test.com{ server 127.0.0.1:8080; } server { listen 80; listen 443 ssl http2; ssl_certificate /usr/local/nginx/conf/ssl/www.test.com.pem; ssl_certificate_key /usr/local/nginx/conf/ssl/www.test.com.key; server_name www.test.com; access_log /data/wwwlogs/www.test.com_nginx.log combined; index index.html index.htm index.jsp; root /data/wwwroot/www.test.com; ? location ~ .*\.(js|css)?$ { proxy_pass http://www.test.com; expires 7d; access_log off; } ? location / { proxy_pass http://www.test.com; include proxy.conf; } }
?
天第一次看HTML5的書籍,嘗試使用記事本編寫第一個網頁,不料,打開網頁后,竟然是亂碼狀態,愁煞吾也,這個問題怎么破呢?經查相關資料,是因為記事本默認存儲的編碼格式與html中的編碼格式不一致導致的.....
情況具體是這樣的:
第一步是將寫好的內容的記事本的后綴“TXT”改成了HTML
打開網頁之后是這樣的:亂碼
查閱資料后,解決方法是這樣的:
在網頁空白處點擊右鍵,找到編碼點擊,選擇UTF-8,問題就解決了。
還有一種方法就是,使用記事本另存為修改后綴名為HTML,編碼處選擇UTF-8,就不會出現亂碼現象了。
基于openjdk,使用-d參數控制持續60s后自動停止,使用瀏覽器打開html報告,內容顯示正常:
[root@test arthas]# /usr/bin/java -jar arthas-boot.jar
[arthas@44794]$ profiler start -e alloc -d 60
Profiling started
profiler will silent stop after 60 seconds.
profiler output file will be: /arthas-output/20240326-171613.html
基于openjdk-openj9,同樣使用-d參數控制持續60s后自動停止,使用瀏覽器打開html報告,內容顯示空白:
[root@test arthas]# /usr/lib/openj9/bin/java -jar arthas-boot.jar
[arthas@7857]$ profiler start -e alloc -d 60
Profiling started
profiler will silent stop after 60 seconds.
profiler output file will be: /arthas-output/20240326-163013.html
profiler對openjdk-openj9的支持還不夠全面,可以通過不加-d參數,主動stop臨時規避:
[root@test arthas]# /usr/lib/openj9/bin/java -jar arthas-boot.jar
[arthas@7857]$ profiler start -e alloc
Profiling started
[arthas@7857]$ profiler stop
OK
profiler output file : /arthas-output/20240326-163522.html
使用這種方法,可以正常輸出基于內存的火焰圖。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。