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

Setup Secure WebSockets #293

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Setup Secure WebSockets #293

wants to merge 2 commits into from

Conversation

CrackTheCode016
Copy link
Collaborator

Previous PR for reference: #35

@CrackTheCode016 CrackTheCode016 requested a review from a team as a code owner January 6, 2025 13:45
@0xLucca 0xLucca requested a review from a team January 6, 2025 13:58
infrastructure/running-a-node/setup-secure-wss.md Outdated Show resolved Hide resolved

1. Install the `nginx` web server:
```bash
apt install nginx
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should add a note somewhere that all the steps presented in this guide are for Ubuntu-like oss

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a note for unix based systems

Copy link
Collaborator

@dawnkelly09 dawnkelly09 left a comment

Choose a reason for hiding this comment

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

Noticed a few things. Thanks!

- 'Setup Secure Websocket': setup-secure-wss.md
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- 'Setup Secure Websocket': setup-secure-wss.md
- 'Set Up Secure Websocket': setup-secure-wss.md

For consistency

wss://example.com:443
```

![A sync-in-progress chain connected to Polkadot.js UI](/images/infrastructure/general/setup-secure-wss/secure-wss-01.webp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This image is missing

@@ -0,0 +1,93 @@
---
title: Setup Secure WebSocket
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
title: Setup Secure WebSocket
title: Set Up Secure WebSocket


LetsEncrypt will auto-generate an SSL certificate and include it in your configuration.

You can generate a self-signed certificate and rely on your node's raw IP address when connecting. However, self-signed certificates aren't optimal because you have to whitelist the certificate to access it from a browser.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
You can generate a self-signed certificate and rely on your node's raw IP address when connecting. However, self-signed certificates aren't optimal because you have to whitelist the certificate to access it from a browser.
When connecting, you can generate a self-signed certificate and rely on your node's raw IP address. However, self-signed certificates aren't optimal because you must include the certificate in an allowlist to access it from a browser.


You can generate a self-signed certificate and rely on your node's raw IP address when connecting. However, self-signed certificates aren't optimal because you have to whitelist the certificate to access it from a browser.

Use the following commmand to generate a self-signed certificate using OpenSSL:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Use the following commmand to generate a self-signed certificate using OpenSSL:
Use the following command to generate a self-signed certificate using OpenSSL:

## Connect to the Node

1. Open [Polkadot.js Apps interface](https://polkadot.js.org/apps){target=\_blank} and click the logo in the top left to switch the node
2. Activate the **Development** toggle and input your node's address - either the domain or the IP address. Remember to prefix with `wss://` and if you're using the 443 port, append `:443` as follows:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
2. Activate the **Development** toggle and input your node's address - either the domain or the IP address. Remember to prefix with `wss://` and if you're using the 443 port, append `:443` as follows:
2. Activate the **Development** toggle and input either your node's domain or IP address. Remember to prefix with `wss://` and, if you're using the 443 port, append `:443` as follows:


### Obtain an SSL Certificate

You can follow the [LetsEncrypt](https://letsencrypt.org/){target=\_blank} instructions for your respective web server implementation to get a free SSL certificate:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
You can follow the [LetsEncrypt](https://letsencrypt.org/){target=\_blank} instructions for your respective web server implementation to get a free SSL certificate:
LetsEncrypt suggests using the [Certbot ACME client](https://letsencrypt.org/getting-started/#with-shell-access/){target=\_blank} for your respective web server implementation to get a free SSL certificate:

I found it confusing when these links didn't open to LetsEncrypt, so added some language to clarify where the user can expect to end up

Apache2 can run in various modes, including `prefork`, `worker`, and `event`. In this example, the [`event`](https://httpd.apache.org/docs/2.4/mod/event.html){target=\_blank} mode is recommended for handling higher traffic loads, as it is optimized for performance in such environments. However, depending on the specific requirements of your setup, other modes like `prefork` or `worker` may also be appropriate.

1. Install the `apache2` web server:
--8<-- 'code/infrastructure/running-a-node/running-a-node/setup-secure-wss/install-apache2.md'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
--8<-- 'code/infrastructure/running-a-node/running-a-node/setup-secure-wss/install-apache2.md'
--8<-- 'code/infrastructure/running-a-node/setup-secure-wss/install-apache2.md'

Code snippet wasn't rendering

RewriteRule /(.*) http://localhost:9944/$1 [P,L]
```

3. Optionally, some form of rate limiting can be introduced:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
3. Optionally, some form of rate limiting can be introduced:
3. Optionally, some form of rate limiting can be introduced by first running the following command:

a2enmod qos
```

And edit `/etc/apache2/mods-available/qos.conf`:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
And edit `/etc/apache2/mods-available/qos.conf`:
Then edit `/etc/apache2/mods-available/qos.conf` as follows:

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

If only there was a way to test this content too 🙈

can we use something like docker-compose to both make this setup easier to achieve, and test-able?

@eshaben eshaben added B0 - Needs Review Pull request is ready for review C1 - Medium Medium priority task A0 - New Content Pull request contains new content pages labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0 - New Content Pull request contains new content pages B0 - Needs Review Pull request is ready for review C1 - Medium Medium priority task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants