簡體   English   中英

如何進行安全請求?

[英]How to make a secure request?

從今天早上開始,我嘗試使用 https 協議在我的遠程數據庫上模擬一個 POST 請求,因為我安裝了一個 ssl 證書。 (我的網站是安全的)。

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

但是,當我嘗試以安全模式向我的數據庫發送 Postman 請求時,出現此錯誤:

SSL Error: Unable to verify the first certificate

當我從 url 中的 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;
        }

}

你知道這是從哪里來的嗎?

 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在這種情況下是為您的服務器和證書內部配置的域的占位符。

看起來您的中間證書配置錯誤。 驗證 site.com.chain.pem 是否包含正確的內容及其路徑是否正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM