janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.48k stars 1.11k forks source link

Reverse Proxy page is insufficient guidance #507

Open opacey opened 1 year ago

opacey commented 1 year ago

Describe the bug

Hi, I tried following the instructions on how to set up an HTTPs reverse proxy: https://github.com/janoside/btc-rpc-explorer/blob/master/docs/nginx-reverse-proxy.md

But it threw errors and wasn't verbose enough to help me resolve. I have found the following steps to work:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install nginx python3-certbot-nginx

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/selfsigned.key -out /etc/ssl/certs/selfsigned.crt
    - complete the form

$ nano ~/.config/btc-rpc-explorer.env
    BTCEXP_HOST=localhost
    BTCEXP_PORT=3002
<ctrl-x>y<enter>

$ sudo cp ~/btc-rpc-explorer/docs/explorer.btc21.org.conf /etc/nginx/sites-available/<fqdn>
$ sudo certbot --text --agree-tos --email <email_addr> -d <fqdn> --manual --preferred-challenges dns --expand --renew-by-default certonly
    - follow certbot's on-screen instructions

$ sudo nano /etc/nginx/sites-available/info.aeio.uk
    server {
            listen 3003 ssl;
            listen [::]:3003 ssl;
            server_name <fqdn>;

            ssl_certificate        /etc/ssl/certs/selfsigned.crt;
            ssl_certificate_key    /etc/ssl/private/selfsigned.key;

            error_page 497 301 =307 https://$host$request_uri;
            location / {
                    proxy_pass http://localhost:3002;
                    proxy_redirect off;
                    proxy_set_header Host $host:$server_port;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Ssl on;
            }
    }
<ctrl-x>y<enter>

$ sudo ln -s /etc/nginx/sites-available/info.aeio.uk /etc/nginx/sites-enabled/info.aeio.uk
$ exit

Environment (please complete the following information):

Configuration file content

Please include the content from the following files. BE SURE TO MODIFY YOUR CREDENTIALS BEFORE SUBMITTING!!!

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots or Log Output

If applicable, add screenshots or log output to help explain your problem.

Additional context

Add any other context about the problem here.