【问题标题】:How to make a secure request?如何提出安全请求?
【发布时间】:2022-10-04 22:28:40
【问题描述】:

从今天早上开始,我尝试使用 https 协议在远程数据库上模拟 POST 请求,因为我安装了 ssl 证书。 (我的网站是安全的)。

https://example.com/api/v1/data_tag

但是当我尝试以安全模式向我的数据库发送邮递员请求时,我收到此错误:

SSL Error: Unable to verify the first certificate

当我从我的网址中的 https 中删除“s”时,请求已正确完成。

http://biotagsensor.com:3000/api/v1/data_tag

我以这种方式配置了我的服务器的防火墙:

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW IN    Anywhere
80/tcp                     ALLOW IN    Anywhere
443/tcp                    ALLOW IN    Anywhere
80/tcp (Nginx HTTP)        ALLOW IN    Anywhere
3000                       ALLOW IN    Anywhere
22/tcp (v6)                ALLOW IN    Anywhere (v6)
80/tcp (v6)                ALLOW IN    Anywhere (v6)
443/tcp (v6)               ALLOW IN    Anywhere (v6)
80/tcp (Nginx HTTP (v6))   ALLOW IN    Anywhere (v6)
3000 (v6)                  ALLOW IN    Anywhere (v6)

这是 nginx 的默认文件:

upstream backend {
        server localhost:3000;
}

server {
  listen 80;
  rewrite ^ https://$host$request_uri? permanent;
}

server {
#        listen 80 default_server;
#        listen [::]:80 default_server;

        listen 443 ssl;

        ssl_certificate /home/debian/site.com.chain.pem;
        ssl_certificate_key /home/debian/myserver.key;

        root /home/debian/site.com/dist;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location  ^~ /api {
               proxy_redirect off;
               proxy_http_version 1.1;
               proxy_pass http://backend;
               proxy_set_header Host $host ;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       }


        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

}

你知道这可能来自哪里吗?

【问题讨论】:

    标签: nginx ssl https postman ssl-certificate


    【解决方案1】:
     http://ipadress:3000/api/v1/data_tag
    

    这是您的内部服务器,未启用 HTTPS。您甚至可以从您的 nginx 使用纯 HTTP 显式访问此服务器:

               proxy_pass http://backend;
    

    如果要使用 nginx 中配置的 HTTPS,则需要使用 nginx 中为 HTTPS 配置的端口,即

      https://example.com:443/api/v1/data_tag
    

    或者更简单,因为 443 是 HTTPS 的默认端口:

      https://example.com/api/v1/data_tag
    

    example.com 在这种情况下是您的域的占位符,它是为您的服务器和证书内部配置的。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-17
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 2014-07-06
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多