apache 禁用TRACE / TRACK方法,及测试过程

apache 禁用TRACE / TRACK方法

禁用方法

在httpd.conf 中增加一行“TraceEnable off”

本地测试过程

通过telnet到HTTP的某个服务端口,进行测试,如下描述 (红色为需要输入的部分)。
关闭前测试会返回200 OK:

[root@web001 ~]$ telnet xxx.xxx.xxx.xxx 80
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx).
Escape character is '^]'.
TRACE / HTTP/1.0
X-Test:abcde
HTTP/1.1 200 OK
Date: Wed, 18 Jul 2012 06:49:19 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_jk/1.2.28
Connection: close
Content-Type: message/http
TRACE / HTTP/1.0
X-Test: abcde
Connection closed by foreign host.

关闭后测试会返回405 Method Not Allowed:

[root@web001 ~]$ telnet xxx.xxx.xxx.xxx 80
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx).
Escape character is '^]'.
TRACE / HTTP/1.0
X-Test:abcde
HTTP/1.1 405 Method Not Allowed
Date: Wed, 18 Jul 2012 06:50:05 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_jk/1.2.28
Allow:
Content-Length: 223
Connection: close
Content-Type: text/html; charset=iso-8859-1
X-Pad: avoid browser bug
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method TRACE is not allowed for the URL /.</p>
</body></html>
Connection closed by foreign host.

课程分享:

安利一门Python超级好课!
扫码下单输优惠码【csdnfxzs】再减5元,比官网还便宜!
安利一门Python超级好课!扫码下单输优惠码【csdnfxzs】再减5元,比官网还便宜!
https://marketing.csdn.net/poster/109?utm_source=NEWFXDT

using CommunityToolkit.Mvvm.ComponentModel; using Liudin.Acs; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; namespace Liudin.App.ViewModels.bar { public partial class InfoBarViewModel : BaseViewModel { private readonly Singleton config; private readonly SynchronizationContext _syncContext; public InfoBarViewModel(Singleton _config) { config = _config; // 构造函数中捕获UI线程上下文 _syncContext = SynchronizationContext.Current ?? new SynchronizationContext(); ShowInfo(); } [ObservableProperty] private string infoText = "机器没有上电,请打开电源开关"; [ObservableProperty] private Brush? fontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#006400")); /// <summary> /// 设置字体颜色 0-正常 1-警告 2-错误 /// </summary> /// <param name="lev"></param> private void SetMsgColor(int lev) { switch (lev) { case 0: FontColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#006400")); break; case 1: FontColor = Brushes.Orange; break; case 2: FontColor = Brushes.Red; break; } } private void ShowInfo() { try { Task.Run(async () => { while (config.IsUpdateInfo) { _syncContext.Post(_ => { InitInfo(); }, null); await Task.Delay(200); } }); } catch (TaskCanceledException) { /* 处理取消 */ } } private void InitInfo() { string msg = ""; if (JSGS.bPowerOn) { SetMsgColor(2); msg = "机器没有上电,请打开电源开关"; } else if (JSGS.bEStop) { SetMsgColor(2); msg = "急停开关已打开,处理好,关闭急停开关"; } else if (App.Current.m_bBgnHome) { SetMsgColor(1); msg = "机器启动,请回零"; } else if (JSGS.bToHome) { SetMsgColor(1); msg = "急停开关已关闭,请回零"; } else if (JSGS.bAlarm) { SetMsgColor(2); msg = "机器报警,请停止检查"; } else if (JSGS.bHoming) { SetMsgColor(1); msg = "机器正在回零..."; } else if (JLimit(ref msg)) { SetMsgColor(1); } else if (JSGS.bRunning) { SetMsgColor(0); msg = "系统正在自动运行中..."; } else { SetMsgColor(0); msg = "系统准备就绪,等待中..."; } } } } 优化该代码
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值