0

I'm config the nginx using together frontend and backend the same domain like

my-domain.com -> frontend

my-domain.com/api/ -> backend.

When running HTTP it's run ok, but I'm config https, it's not run the first request. I don't know what wrong.

Frontend I'm using NextJs, SSR framework

I'm using isomorphic-unfetch request.

Please help me, Thanks.

upstream customer-ssr {
    server 127.0.0.1:3030;
    keepalive 64;
}

server {
    listen 80;
    server_name  my-domain.com www.my-domain.com;
    return 301 https://my-domain.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name www.my-domain.com;
    return 301 $scheme://my-domain.com$request_uri;
}

server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    server_name my-domain.com;

    root     /home/my-domain/my-domain-web/current;

    ssl_certificate /etc/nginx/ssl/my-domain.com.crt;
    ssl_certificate_key /etc/nginx/ssl/my-domain.com.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    add_header          Strict-Transport-Security "max-age=31536000; includeSubdomains";

    location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_max_temp_file_size 0;
        proxy_pass http://customer-ssr;
        proxy_redirect off;
        proxy_read_timeout 240s;
    }

    location /api/ {
       proxy_buffering       off;
       proxy_set_header      Host              $proxy_host;
       proxy_set_header      X-Real-IP         $remote_addr;
       proxy_set_header      X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header      X-Forwarded-Proto $scheme;
       proxy_pass            http://110.95.104.901:8888;
    }
}
Community
  • 1
  • 1
Vo Manh Kien
  • 35
  • 2
  • 8

1 Answers1

-1

Write this line on you main(index/server).js file:

/**
 * Handle UNABLE_TO_VERIFY_LEAF_SIGNATURE error
**/
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
barbsan
  • 3,418
  • 11
  • 21
  • 28