![Nginx 反向代理不起作用](https://linux22.com/image/773333/Nginx%20%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
配置 TheHive 事件响应平台后,我尝试将重定向域配置为 ip 地址,但不起作用。当我在浏览器上输入 ip 地址时,我可以访问网页。使用域名则无法访问。我使用“nslookup thehive.example.com”检查,它显示了正确的 ip 地址。
注意:我在我们的 DNS 服务器中将域名重定向到 IP 地址
server {
listen 443 ssl;
server_name thehive.example.com;
# ssl on;
ssl_certificate /etc/nginx/ssl/thehive_cert.pem;
ssl_certificate_key /etc/nginx/ssl/thehive_key.pem;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
client_max_body_size 2G;
proxy_buffering off;
client_header_buffer_size 8k;
location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
proxy_pass http://127.0.0.1:9000/;
proxy_http_version 1.1;
proxy_set_header Connection "" ;
}
}
这里是 curl 结果
curl -v http://thehive.example.com
* Could not resolve host: thehive.example.com
* Closing connection 0
curl: (6) Could not resolve host: thehive.example.com
当我使用 ip 地址进行 curl 时,它起作用了
curl -v http://192.168.42.11:9000/index.html
* Trying 192.168.42.11:9000...
* TCP_NODELAY set
* Connected to 192.168.42.11 (192.168.42.11) port 9000 (#0)
> GET /index.html HTTP/1.1
> Host: 192.168.42.11:9000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Request-Time: 1
< Accept-Ranges: bytes
< Cache-Control: public, max-age=3600
< Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
< Date: Tue, 21 Dec 2021 05:34:12 GMT
< Content-Type: text/html; charset=UTF-8
< Content-Length: 1191
<
<!doctype html> <html ng-app="thehive"> <head> <meta charset="utf-8"> <title ng-bind="'TheHive' + (title ? ' - ' + title : '')"></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width"> <!-- <link rel="icon" type="image/png" href="images/favicon.png" /> --> <link rel="icon" type="image/png" href="images/favicons/favicon-196x196.png" sizes="196x196"> <link rel="icon" type="image/png" href="images/favicons/favicon-96x96.png" sizes="96x96"> <link rel="icon" type="image/png" href="images/favicons/favicon-32x32.png" sizes="32x32"> <link rel="icon" type="image/png" href="images/favicons/favicon-16x16.png" sizes="16x16"> <link rel="icon" type="image/png" href="images/favicons/favicon-128.png" sizes="128x128"> <link rel="stylesheet" href="styles/vendor.7dd02a27.css"> <link rel="stylesheet" href="styles/app.0688c7a8.css"> <style> app-container { display: block } </style> </head> <body ng-cloak class="hold-transition skin-blue layout-top-nav"> <page-loader flag="isLoading" bg-col* Connection #0 to host 192.168.42.11 left intact
or="#ecf0f5"></page-loader> <div ui-view></div> <script src="scripts/vendor.78eed977.js"></script> <script src="scripts/scripts.dcfd7451.js"></script> </body> </html>
答案1
没有thehive.example.com
DNS 条目。因此您的浏览器curl
无法解析其 IP 地址。
您需要添加 DNS 条目,或者hosts
在您发出请求的系统上的文件中添加条目。