Apache url 无法访问

发布于 2024-11-10 14:21:08 字数 803 浏览 6 评论 0原文

我必须检查 apache 服务器的访问。我编写了一个独立的代码来检查 apache 服务器的访问。如果我只是输入 url,它是可以访问的...但是当我通过代码运行它时,它会抛出异常..

as java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.98.12.151:80/server-status?auto

403 响应代码是什么? 我可以让它从独立代码访问吗...

这是我的代码 connecturl = "http://" + ip + ":" + 端口 + "/server-status?auto"; targetURL = 新 URL(connecturl); HttpURLConnection httpURLConnection = (HttpURLConnection) targetURL.openConnection();

        httpURLConnection.setUseCaches(false);

        httpURLConnection.setAllowUserInteraction(false);

        httpURLConnection.setDoInput(true);

        httpURLConnection.setRequestMethod("GET");


        httpURLConnection.connect();

I have to check the access of a apache server.I have written a standalone code for cheking the access of a apache server. If i simply type the url it is accessable...But wen i run it through code it throws exception..

as java.io.IOException: Server returned HTTP response code: 403 for URL: http://10.98.12.151:80/server-status?auto

What is 403 response code ??
hw can i make it accessible from standalone code...

This is my code
connecturl = "http://" + ip + ":" + port + "/server-status?auto";
targetURL = new URL(connecturl);
HttpURLConnection httpURLConnection = (HttpURLConnection) targetURL.openConnection();

        httpURLConnection.setUseCaches(false);

        httpURLConnection.setAllowUserInteraction(false);

        httpURLConnection.setDoInput(true);

        httpURLConnection.setRequestMethod("GET");


        httpURLConnection.connect();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扛起拖把扫天下 2024-11-17 14:21:08

403 代码是“访问被拒绝”代码。其他代码定义可以在 w3.org 找到

原因可能是由于httpd.conf 文件中的 to 指令没有“允许来自”,其中包含您尝试运行程序的主机的 IP。

例如,您尝试从客户端 (10.98.12.10) 运行此程序,并希望检查在 10.98.12.151 上运行的 Web 服务器的状态。

确保服务器上的 httpd.conf 文件具有类似以下内容:

<Location /server-status>
  SetHandler server-status
  Order deny,allow
  Deny from all
# now make sure your client host is allowed to connect to this location
  Allow from 10.98.12.10
</Location>

祝你好运。

The 403 code is an "access denied" code. Other codes definitions can be found at w3.org

The cause is likely due to directive in your httpd.conf file not having an "Allow from" that includes the ip of the host you're trying to run the program on.

For example, you're trying running this from a client (10.98.12.10) and want to check the status of the webserver you have running on 10.98.12.151.

Make sure the httpd.conf file on the server has something like the following:

<Location /server-status>
  SetHandler server-status
  Order deny,allow
  Deny from all
# now make sure your client host is allowed to connect to this location
  Allow from 10.98.12.10
</Location>

Good luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文