1

背景

眼镜:

OctoPrint 1.3.4(主分支)

Apache/2.4.10 (Debian) 使用 mod_proxy

我正在尝试在我的 Apache 服务器上运行反向代理到OctoPrint,如开发人员的反向代理配置示例中指定的那样。

这是我的虚拟主机中的 Apache 代理配置:

<Location "/3d">
            AuthType Basic
            AuthName "-----------"
            AuthBasicProvider file
            AuthUserFile "------------------"
            Require user -------------

            ProxyPass "http://192.168.------:5000"
            ProxyPassReverse "http://192.168.------:5000"

            RequestHeader set X-SCRIPT-NAME /3d/
            RequestHeader set X-SCHEME https
</Location>

但是,通过代理成功加载 OctoPrint 界面后,我无法登录,出现错误:

POST https://-----------/3d/api/login 400 (Bad Request)在 Chrome 的网络标签中。

这是两个代理的请求标头:

POST /3d/api/login HTTP/1.1
Host: -------------
Connection: keep-alive
Content-Length: 16
Authorization: Basic -----------------
Origin: ----------------
User-Agent: --------------
Content-Type: application/json; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Cache-Control: no-cache
X-Requested-With: XMLHttpRequest
X-Api-Key: -------------------
Referer: https://----------/3d
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
Cookie: session_P443=----------------; PHPSESSID=-------------; JSESSIONID=dummy

并直接从本地 IP(不通过代理):

POST /api/login HTTP/1.1
Host: 192.168.0.-------:5000
Connection: keep-alive
Content-Length: 16
Origin: http://192.168.0.------:5000
User-Agent: -------------
Content-Type: application/json; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Cache-Control: no-cache
X-Requested-With: XMLHttpRequest
X-Api-Key: --------------
Referer: http://192.168.0.------:5000/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
Cookie: session_P5000=-------------------------------

问题

是什么导致了这个POST https://-----------/3d/api/login 400 (Bad Request)错误,我该如何解决?

提前谢谢!

4

1 回答 1

1

没关系,Mod_Security 阻止了包含 JSON 的 POST 请求。

看看日志假人。

于 2017-11-04T04:37:39.850 回答