顯示具有 tomcat 標籤的文章。 顯示所有文章
顯示具有 tomcat 標籤的文章。 顯示所有文章

2025年5月19日 星期一

2025年5月16日 星期五

[研究]用 curl -I 檢測Web Server軟體種類、版本

[研究]用 curl -I 檢測Web Server軟體種類、版本

2025-05-16

用 curl -I

Microsoft網站看不出來

C:\>curl -I https://microsoft.com/
HTTP/1.1 301 Moved Permanently
Date: Thu, 15 May 2025 06:50:21 GMT
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
Location: https://www.microsoft.com/
x-azure-ref: 20250515T065021Z-17fc6f5689742cs8hC1TPErcmn0000000kfg0000000084u3
Strict-Transport-Security: max-age=31536000
X-Cache: CONFIG_NOCACHE

C:\>


C:\>curl -I https://www.ptt.cc
HTTP/1.1 302 Found
Date: Thu, 15 May 2025 06:46:58 GMT
Content-Type: text/html
Connection: keep-alive
Server: cloudflare
Cf-Ray: 9400ae65088ed7a7-LAX
Location: https://www.ptt.cc/index.html
Cache-Control: max-age=3600s, public
Cf-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=pQ1LblRBjo7G1SfLciahmWF5u23o5LIlszgMtGjCKurwZp6d2luPoKEpPgF9A2RhOQ7Ns8CaRiZDsBX%2B14AZGaEVz0qal9fEFGk67ZtcaBOxHpWH%2F46OUZUK5ieo"}],"group":"cf-nel","max_age":604800}
Nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Strict-Transport-Security: max-age=0
X-Content-Type-Options: nosniff
alt-svc: h3=":443"; ma=86400
server-timing: cfL4;desc="?proto=TCP&rtt=134799&min_rtt=133794&rtt_var=39477&sent=6&recv=6&lost=0&retrans=0&sent_bytes=3281&recv_bytes=380&delivery_rate=32111&cwnd=254&unsent_bytes=0&cid=cd4b51c297d2f7cd&ts=456&x=0"


C:\>curl -I https://24h.pchome.com.tw/
HTTP/1.1 302 Found
server: nginx
date: Thu, 15 May 2025 06:40:01 GMT
content-type: text/html
location: https://24h.pchome.com.tw/
via: 1.1 google
X-CDN-CACHE-STATUS: miss
Transfer-Encoding: chunked
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000


C:\>curl -I https://www.hinet.net
HTTP/1.1 403 Forbidden
Server: HiNetCDN
Date: Thu, 15 May 2025 06:39:00 GMT
Content-Type: text/plain
Connection: keep-alive
content-length: 10
x-request-id: e490573edebb5ee2a4ac3ff809923a32
X-Cache: RULE


C:\>curl -I https://www.google.com
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-h0oGCAOVIurhZ5lnJHu-lA' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
Accept-CH: Sec-CH-Prefers-Color-Scheme
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Date: Thu, 15 May 2025 06:39:16 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Expires: Thu, 15 May 2025 06:39:16 GMT
Cache-Control: private
Set-Cookie: AEC=AVcja2fe4mJ4q33gWnl4k1C1wEnbnrOK-TKTtYfdbYdG_3K2To0WhSTFUQ; expires=Tue, 11-Nov-2025 06:39:16 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax
Set-Cookie: NID=524=s7jqh_ngnnMVZX_kt5hwWH05I3MDy-k0jtX7yZloBN8aCGYrDR2qSjYWzcWYXujTfDQv3VG6re5gbrg65BiTqM0GKXwUyj7aLpsw2k8Is4_tSCdi5_oIWbAd4c9SqL6N5xgS9ulhbirkmRlZZ_X2nbMpdV3evrtuv5fXV7ajWAl0eD_T21_zrgP4rB42WJF6pFcxC0pr-Dt4mVs; expires=Fri, 14-Nov-2025 06:39:16 GMT; path=/; domain=.google.com; HttpOnly
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000


C:\>curl -I https://www.nycu.edu.tw/
HTTP/1.1 303 303
Date: Thu, 15 May 2025 06:56:04 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
Content-Security-Policy: default-src 'self';script-src 'unsafe-eval';frame-ancestors 'self' *.instagram.com maps.googleapis.com fonts.googleapis.com *.youtube.com; connect-src 'self' 'unsafe-inline' https://directline.botframework.com wss://directline.botframework.com https://analytics.google.com https://graph.facebook.com;base-uri 'self';font-src 'self' *.nycu.edu.tw;form-action 'self' *.google.com;style-src 'self' 'unsafe-inline' 'unsafe-eval' ;object-src 'none';img-src data: 'self' data: blob: 'unsafe-inline' 'unsafe-eval' *.nycu.edu.tw *.googletagmanager.com *.google-analytics.com *.analytics.google.com *.g.doubleclick.net *.google.com *.google.com.tw *.youtube.com *.googleapis.com *.gstatic.com maps.googleapis.com fonts.googleapis.com i3.ytimg.com www.googletagmanager.com *.facebook.com i.ytimg.com *.instagram.com *.cdn.botframework.com *.directline.botframework.com https://scontent-tpe1-1.xx.fbcdn.net;script-src-elem 'self' 'unsafe-inline' *.googletagmanager.com *.google.com *.instagram.com *.googleapis.com *.gstatic.com maps.googleapis.com https://cdn.botframework.com/botframework-webchat/latest/webchat.js *.youtube.com;frame-src 'self' *.instagram.com maps.googleapis.com fonts.googleapis.com *.youtube.com *.google.com *.facebook.com;
Location: /nycu/ch/index
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: DENY
Content-Language: en-US
Set-Cookie: XSRF-TOKEN=29479531-aff0-4089-b94c-ab20655cd48e; Path=/; Secure;HttpOnly;Secure;SameSite=Strict
Set-Cookie: JSESSIONID=6AABD26AA3303D7AC04FC1E23160D3AC; Path=/; Secure; HttpOnly;HttpOnly;Secure;SameSite=Strict
Strict-Transport-Security: max-age=157680000
Set-Cookie: nctu_id=AAY7BJAlaDtXRhgBAAAAADtfdnfRh3D7QhfQO_wrFypb-T9eegEBZmpshTivkU8DOw==iJMlaA==P7LgW55FTCsa74gNJWJ92bxIbxE=; Domain=.nycu.edu.tw; Path=/; Secure; HttpOnly

自行用 Windows Server 2025 Standard 架設的 IIS 測試


C:\>curl -I http://localhost
HTTP/1.1 200 OK
Content-Length: 703
Content-Type: text/html
Last-Modified: Thu, 15 May 2025 07:13:41 GMT
Accept-Ranges: bytes
ETag: "7e5d18e368c5db1:0"
Server: Microsoft-IIS/10.0
Date: Thu, 15 May 2025 07:16:46 GMT


C:\>

用 Windows Server 2019 Standard 的 IIS 架設的,可能因為在資安設備後面,看不出 IIS 了

C:\>curl -I https://(略)/
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 15361
Content-Type: text/html; charset=utf-8
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000   
Date: Thu, 15 May 2025 07:18:44 GMT


C:\>

也可以用類似  nmap -sV -p 80,443 192.168.1.100 檢測,但慢。

(完)

相關

2024年7月19日 星期五

[研究]能設定 Sesssion Time Out 為無限大或關閉嗎?

[研究]能設定 Sesssion Time Out 為無限大或關閉嗎?

2024-07-19

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

ASP.NET  WebForm 能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 ASP.NET WebForms 中,Session 的超時設置是無法設置為無限大或完全關閉的。然而,您可以將超時設置為非常長的時間,以便實際使用中接近無限大。這是透過在 web.config 文件中修改 sessionState 元素來實現的。例如:

<configuration>
  <system.web>
    <sessionState timeout="525600" />
  </system.web>
</configuration>

上述配置將 Session 的超時設置為 525600 分鐘,即一年。這已經是一個相當長的時間,但仍然不是無限大。

另外一點需要注意的是,這樣設置並不一定是最佳實踐,因為長時間的 Session 會佔用更多的服務器資源,並且可能會導致其他潛在的性能和安全問題。一般來說,最好根據應用程序的需求來設置適當的 Session 超時時間,並且在必要時通過其他機制(例如,持久性存儲)來保存用戶狀態。

********************************************************************************

IIS  能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 IIS (Internet Information Services) 中,也無法將 Session 超時設置為無限大或完全關閉。但同樣地,您可以設置一個非常長的超時時間。

在 IIS 中,Session 超時設置是通過應用程序池的閒置超時設置來控制的。雖然您無法將其設置為無限大,但可以將其設置為非常大的數值。以下是如何在 IIS 中修改應用程序池的閒置超時設置:

  1. 打開 IIS 管理器:按下 Win + R 鍵,輸入 inetmgr,然後按下 Enter 鍵。
  2. 選擇您的應用程序池:在左側面板中展開 本地計算機,選擇 應用程式池。
  3. 修改應用程序池設置:在中間面板中選擇您的應用程序池,然後在右側面板中點擊 進階設定。
  4. 修改閒置超時(Idle Time-out)設置:在彈出的對話框中找到 閒置超時(分鐘)(Idle Time-out (minutes))設置,將其值設置為所需的分鐘數。例如,將其設置為 525600 分鐘,即一年。

儘管如此,這個設置還是有其限制和風險。長時間保持閒置的 Session 會佔用更多的服務器資源,並可能引起性能問題。因此,應該根據應用程序的具體需求進行設置,並考慮使用其他方式來保存用戶狀態,如持久化存儲。

總結來說,無論是在 ASP.NET WebForms 還是 IIS 中,都無法將 Session 超時設置為無限大或完全關閉,但可以設置為非常長的時間。

********************************************************************************

tomcat 能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 Apache Tomcat 中,您無法將 Session 超時設置為無限大或完全關閉,但您可以將其設置為非常長的時間。

在 Tomcat 中,Session 超時時間是通過 web.xml 文件中的 <session-config> 元素進行配置的。您可以將 Session 超時設置為非常大的數值來接近無限大。以下是如何進行配置的示例:

  1. 打開您的 web.xml 文件,該文件通常位於您的 Web 應用程序的 WEB-INF 目錄中。
  2. 添加或修改 <session-config> 元素來設置超時時間。例如:

<web-app>
  ...
  <session-config>
    <session-timeout>525600</session-timeout> <!-- 這裡設置為一年(以分鐘計) -->
  </session-config>
  ...
</web-app>

這樣設置將 Session 的超時時間設置為 525600 分鐘,即一年。

同樣地,這種設置並不一定是最佳實踐,因為長時間的 Session 會佔用更多的服務器資源,並可能導致其他潛在的性能和安全問題。最好根據應用程序的需求來設置適當的 Session 超時時間,並且在必要時通過其他機制(例如,持久性存儲)來保存用戶狀態。

總結來說,在 Tomcat 中,無法將 Session 超時設置為無限大或完全關閉,但可以設置為非常長的時間。

********************************************************************************

apache httpd web server 能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 Apache HTTPD Web 伺服器中,設定 Session Timeout 為無限大或關閉並不完全可能,因為這通常是由應用程式層級的設定來控制的,而不是直接由 Apache HTTPD 設定的。

不過,你可以通過調整相關的 Apache 模組設定來影響 Session 行為。以下是一些相關的設定:

1.mod_session 模組: 如果你使用 mod_session 模組來管理 Session,你可以通過設定 SessionTimeout 來調整超時時間。設定為一個非常大的值來實現長時間的 Session。例如:

<IfModule mod_session.c>
    SessionTimeout 31536000
</IfModule>

這裡 31536000 是一年的秒數。

2.mod_auth_cookie 模組: 如果你使用 mod_auth_cookie 來處理 Cookie 的 Session,你可以通過設定 SessionCookieTimeout 來控制 Cookie 的有效期。例如:

<IfModule mod_auth_cookie.c>
    SessionCookieTimeout 31536000
</IfModule>

應用程式層級設定: 如果你使用的是 PHP、Python 或其他語言編寫的應用程式,Session Timeout 的設定通常在應用程式的配置文件中進行。例如,在 PHP 中,你可以在 php.ini 文件中設置 session.gc_maxlifetime 來延長 Session 的有效時間:

<IfModule mod_auth_cookie.c>
    SessionCookieTimeout 31536000
</IfModule>

需要注意的是,將 Session Timeout 設置為非常長的時間或者無限大可能會帶來安全風險,如 Session 劫持。建議根據應用程式的需求和安全考量來設定適當的 Session 超時時間。

********************************************************************************

PHP 能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 PHP 中,將 Session Timeout 設定為「無限大」或「關閉」並不完全可行,但你可以將其設置為一個非常大的值來實現接近無限的效果。這樣的設置會使 Session 在實際使用中不會過期,但仍然會受到 PHP 的垃圾回收機制影響。以下是一些相關的設定:

1、session.gc_maxlifetime: 這個設定定義了 Session 在沒有活動的情況下被回收前的最大時間(以秒為單位)。你可以將其設置為非常大的值來實現長時間不過期的效果,例如一年的秒數(31536000秒):


session.gc_maxlifetime = 31536000  

 

2、session.cookie_lifetime: 這個設定定義了 Session Cookie 的有效期(以秒為單位)。如果你希望 Session Cookie 在瀏覽器關閉後不失效,你可以將其設置為一個非常大的值:.

session.cookie_lifetime = 31536000 

3、session.use_cookies 和 session.use_only_cookies: 確保這些設置是開啟的,以便 Session 通過 Cookie 存儲:.

session.use_cookies = 1

session.use_only_cookies = 1  

4、session.gc_probability 和 session.gc_divisor: 這些設定控制垃圾回收機制的機率。可以調整這些設定來影響 Session 的清理頻率。默認值是 gc_probability = 1 和 gc_divisor = 100,意味著每 100 次請求中 1 次會進行垃圾回收。

session.gc_probability = 1   

session.gc_divisor = 100

雖然這些設置可以延長 Session 的有效時間,但完全關閉 Session 超時仍然是不現實的,並且這樣做會帶來潛在的安全風險,如 Session 劫持或資源泄漏。建議根據實際需要來設定合理的超時時間,並定期進行安全性檢查。

********************************************************************************

JSP 能設定 Sesssion Time Out 為無限大或關閉嗎?

ChatGPT

在 JSP (JavaServer Pages) 中,Session Timeout 的設定可以通過 Web 應用程式的 web.xml 文件來進行。雖然不能完全將 Session Timeout 設置為無限大或關閉,但你可以將其設置為非常大的值來實現長時間不過期的效果。

以下是一些設定步驟:

1、設定 Session Timeout:

在 web.xml 文件中,你可以設定 <session-config> 元素來定義 Session 的超時時間。這裡的時間以分鐘為單位。例如,設置為一年的秒數(525600分鐘):

<session-config>
    <session-timeout>525600</session-timeout> <!-- 一年的分鐘數 -->
</session-config>

這樣設置後,Session 將在 525600 分鐘(即 1 年)內不會自動過期。

2、在應用程式中控制 Session Timeout:

如果你需要在應用程式層級動態調整 Session 的超時時間,可以在 JSP 或 Servlet 中使用以下代碼:.

HttpSession session = request.getSession();
session.setMaxInactiveInterval(31536000); // 設置為一年(秒數)  

setMaxInactiveInterval 方法接受的參數是秒數。這樣設置後,Session 的超時時間將會是 31536000 秒(即 1 年)。

3、注意安全風險:

將 Session Timeout 設置為非常長的時間或無限大可能會導致安全問題,例如 Session 劫持或其他安全風險。建議根據實際需求和安全考量來設定合理的 Session 超時時間,並定期檢查和更新安全策略。

總之,雖然你不能完全關閉 Session Timeout,但可以將其設置為非常大的值來達到類似的效果。

********************************************************************************

(完)

相關

2022年9月8日 星期四

[研究]Apache Tomcat 10.0.23安裝、功能檢視(Win2022)

[研究]Apache Tomcat 10.0.23安裝、功能檢視(Windows Server 2022)

2022-09-07

官方網站
https://tomcat.apache.org/

請先自己下載安裝 JRE ( Microsoft OpenJDK、Oracle Java JRE、、、)

















********************************************************************************
以下只是看看提供了些甚麼,上面已經安裝完成。











































(完)

相關

[研究]Apache Tomcat 10.0.23安裝、功能檢視(Win2022)
https://shaurong.blogspot.com/2022/09/apache-tomcat-10023win2022.html

[研究]Tomcat 出現「無法存取此捷徑所參照的項目。您可能沒有適當的權限。」之解決(Win10)
https://shaurong.blogspot.com/2022/09/tomcat.html

[研究]Apache Tomcat 10.0.23最小安裝、預設安裝、完整安裝比較(Win10)
https://shaurong.blogspot.com/2022/09/apache-tomcat-10023win10.html

[研究]Apache Tomcat 9.0.50安裝(tar.gz) (CentOS 8.4 x64)
https://shaurong.blogspot.com/2021/07/apache-tomcat-9050targz-centos-84-x64.html

[研究] Apache Tomcat 9.0.38 + HTTPS(SSL) + nmap 7.80 支援加密演算法最大長度金鑰 測試
https://shaurong.blogspot.com/2020/10/apache-tomcat-9038-httpsssl-nmap-780.html

[研究] Apache Tomcat 8.5.58 + HTTPS(SSL) + nmap 7.80 支援加密演算法最大長度金鑰 測試
https://shaurong.blogspot.com/2020/10/apache-tomcat-8558-httpsssl-nmap-780.html

[研究] Apache Tomcat 7.0.106 + HTTPS(SSL) + nmap 7.80 支援加密演算法最大長度金鑰 測試
https://shaurong.blogspot.com/2020/10/apache-tomcat-70106-httpsssl-nmap-780.html

[研究] Apache Tomcat 7., 8.5.x, 9.x 使用 SSL 連線安裝設定 (Windows Server 2019)
https://shaurong.blogspot.com/2020/10/apache-tomcat-7-ssl.html

[研究] Apache Tomcat 9.0.26 安裝紀錄 (Windows 2019)
https://shaurong.blogspot.com/2019/09/apache-tomcat-9026-windows-2019.html

[研究] Apache Tomcat 9.0.8 服務版 安裝 (Windows 7)
https://shaurong.blogspot.com/2018/06/apache-tomcat-908-windows-7.html