Home > Enterprise >  How to make a secure request?
How to make a secure request?

Time:10-05

Since this morning I try to simulate a POST request on my remote database with the https protocol because I installed an ssl certificate. (my site is secure).

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

But when I try to send a Postman request to my database in secure mode I get this error :

SSL Error: Unable to verify the first certificate

When I remove the "s" from https in my url the request is done correctly.

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

I have configured the firewalls of my server in this way :

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)

and here is the default file of 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;
        }

}

Do you know where this can come from ?

CodePudding user response:

 http://ipadress:3000/api/v1/data_tag

This is your internal server, which is not HTTPS enabled. You even access this server explicitly with plain HTTP from your nginx:

           proxy_pass http://backend;

If you want to use the HTTPS configured in nginx, you need to use the port configured for HTTPS in nginx, i.e.

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

Or simpler, since 443 is the default port for HTTPS:

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

example.com in this case is the placeholder for your domain which is configured for your server and inside the certificate.

CodePudding user response:

It looks like you have a misconfigured intermediate certificate. Verify if site.com.chain.pem has correct content and the path to it is correct.

  • Related