Uppy Companion on https with reverse proxy with Nginix

Hi,
I’ve been trying to setup Uppy Companion on a https public domain (say for example abc.com). When I access the URL https://abc.com on a browser, I’m able to see the response from Companion, which means Nginix and the reverse proxy is working.

The problem, I’m facing is that when I click Google Drive, the oauth is redirected to http://abc.com/drive/redirect and not https.

My authorized redirect URL on Google is
https://abc.com/drive/redirect

My companion is configured as below:

server: {
    host: "http://localhost:3030",
    protocol: "http",
    oauthDomain: "abc.com",
    validHosts: ["abc.com"]
  },

companion.socket(3030);

and my nginix config is

worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       443 ssl;
		listen       [::]:443 default_server;
        server_name  abc.com;
		ssl_certificate "companionSSL.pem";
        ssl_certificate_key "companionSSLkey.pem";
		
   location / {
      proxy_pass http://localhost:3030;
	  proxy_set_header Upgrade $http_upgrade;
	  proxy_set_header Connection "upgrade";  
   }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
            }
}

Appreciate any help on this.

Thanks in advance.

Hi,

An update on this one, I changed the server config as below:

server: {
    host: "localhost:3030",
    protocol: "http",
    oauthDomain: "https://abc.com",
    path:""
  },

and when I access Google Drive, I get an invalid request error. If you notice, the url is prefixed with “http://” which I believe is coming from server.protocol.

I did some dig through the code and I found this code on line 83, here

 grantConfig[authProvider].redirect_uri = `${server.protocol}://${oauthDomain}${fullRedirectPath}`

I’m guessing, this line is what is causing an issue.

In my scenario, I have an HTTPS public domain that is reversed proxied to an HTTP localhost, and this line of code applies HTTP to both.