Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable SSL for block explorer #24

Merged
merged 6 commits into from
Oct 24, 2024
Merged

Conversation

parketh
Copy link
Contributor

@parketh parketh commented Oct 24, 2024

Summary

This PR updates the Blockscout deployment configs to support SSL.

Details

The Blockscout docker compose uses an nginx reverse proxy to route traffic between internal containers (frontend, backed, stats etc). We add a second nginx instance at the server level to route domain traffic to the internal Docker network.

The frontend also makes calls to its own /api, /socket routes. Since the site is setup for SSL we need to config these to use their secure variants (https, wss) in Blockscout.

Server-level nginx:

server {
    listen 443 ssl;
    server_name tohma.explorer.snapcha.in;

    ssl_certificate /etc/letsencrypt/live/tohma.explorer.snapcha.in/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/tohma.explorer.snapcha.in/privkey.pem;

    location ~ ^/(api|socket|sitemap.xml|auth/auth0|auth/auth0/callback|auth/logout) {
        proxy_pass http://localhost:80;
        proxy_http_version 1.1;
        proxy_set_header Host $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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location / {
        proxy_pass http://localhost:80;
        proxy_http_version 1.1;
        proxy_set_header Host $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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Test plan

Visit https://tohma.explorer.snapcha.in/

Comment on lines 26 to 34
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
sed -i '' "s|^L1_OUTPUT_ORACLE_CONTRACT=.*|L1_OUTPUT_ORACLE_CONTRACT=$OUTPUT_ORACLE_ADDRESS|" "$ENV_FILE"
else
# Linux and others
sed -i "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
sed -i "s|^L1_OUTPUT_ORACLE_CONTRACT=.*|L1_OUTPUT_ORACLE_CONTRACT=$OUTPUT_ORACLE_ADDRESS|" "$ENV_FILE"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also use the sed -i.bak which works on both macOS and Linux, but need to remove the generated backup file, like:

sed -i.bak "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
rm $ENV_FILE.bak

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated!

@parketh parketh merged commit 10aa240 into main Oct 24, 2024
1 check passed
@parketh parketh deleted the feat/block-explorer-enable-ssl-2 branch October 24, 2024 14:19
@@ -0,0 +1,18 @@
#!/bin/bash
Copy link
Member

@bap2pecs bap2pecs Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a Make command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants