Skip to content

Commit 0076e63

Browse files
CrackTheCode016nhussein11dawnkelly09eshaben
authored
Setup Secure WebSockets (#293)
* add wss docs * address comments * fix: adding missing image * Apply suggestions from code review Co-authored-by: Dawn Kelly <[email protected]> * fix: merging issues * Apply suggestions from code review Co-authored-by: Erin Shaben <[email protected]> --------- Co-authored-by: nhussein11 <[email protected]> Co-authored-by: Nicolás Hussein <[email protected]> Co-authored-by: Dawn Kelly <[email protected]> Co-authored-by: Erin Shaben <[email protected]>
1 parent 6fc26a4 commit 0076e63

File tree

11 files changed

+142
-10
lines changed

11 files changed

+142
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JsonRpcProvider } from 'ethers';
22

33
const provider = new JsonRpcProvider(
4-
'https://westend-asset-hub-eth-rpc.polkadot.io',
4+
'https://westend-asset-hub-eth-rpc.polkadot.io'
55
);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```apacheconf
2+
# (...)
3+
SSLProxyEngine on
4+
ProxyRequests off
5+
ProxyPass / ws://localhost:9944
6+
ProxyPassReverse / ws://localhost:9944
7+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```bash
2+
apt install apache2
3+
a2dismod mpm_prefork
4+
a2enmod mpm_event proxy proxy_html proxy_http proxy_wstunnel rewrite ssl
5+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```bash
2+
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/selfsigned.key -out /etc/ssl/certs/selfsigned.crt
3+
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
4+
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
```conf
2+
server {
3+
(...)
4+
location / {
5+
proxy_buffers 16 4k;
6+
proxy_buffer_size 2k;
7+
proxy_pass http://localhost:9944;
8+
proxy_http_version 1.1;
9+
proxy_set_header Upgrade $http_upgrade;
10+
proxy_set_header Connection "Upgrade";
11+
proxy_set_header Host $host;
12+
}
13+
}
14+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```conf
2+
http {
3+
limit_req_zone "$http_x_forwarded_for" zone=zone:10m rate=2r/s;
4+
(...)
5+
}
6+
location / {
7+
limit_req zone=zone burst=5;
8+
(...)
9+
}
10+
```

.snippets/code/tutorials/interoperability/xcm-transfers/from-relaychain-to-parachain/reserve-backed-transfer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ import { Binary } from 'polkadot-api';
2525

2626
// Create Polkadot client using WebSocket provider for Polkadot chain
2727
const polkadotClient = createClient(
28-
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001')),
28+
withPolkadotSdkCompat(getWsProvider('ws://127.0.0.1:8001'))
2929
);
3030
const dotApi = polkadotClient.getTypedApi(dot);
3131

3232
// Create Astar client using WebSocket provider for Astar chain
3333
const astarClient = createClient(
34-
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000')),
34+
withPolkadotSdkCompat(getWsProvider('ws://localhost:8000'))
3535
);
3636
const astarApi = astarClient.getTypedApi(astar);
3737

@@ -42,7 +42,7 @@ const aliceKeyPair = derive('//Alice');
4242
const alice = getPolkadotSigner(
4343
aliceKeyPair.publicKey,
4444
'Sr25519',
45-
aliceKeyPair.sign,
45+
aliceKeyPair.sign
4646
);
4747

4848
// Define recipient (Dave) address on Astar chain
@@ -56,7 +56,7 @@ const polkadotAssetId = 340282366920938463463374607431768211455n;
5656
// Fetch asset balance of recipient (Dave) before transaction
5757
let assetMetadata = await astarApi.query.Assets.Account.getValue(
5858
polkadotAssetId,
59-
daveAddress,
59+
daveAddress
6060
);
6161
console.log('Asset balance before tx:', assetMetadata?.balance ?? 0);
6262

@@ -65,7 +65,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
6565
dest: XcmVersionedLocation.V3({
6666
parents: 0,
6767
interior: XcmV3Junctions.X1(
68-
XcmV3Junction.Parachain(2006), // Destination is the Astar parachain
68+
XcmV3Junction.Parachain(2006) // Destination is the Astar parachain
6969
),
7070
}),
7171
beneficiary: XcmVersionedLocation.V3({
@@ -75,7 +75,7 @@ const tx = dotApi.tx.XcmPallet.limited_reserve_transfer_assets({
7575
// Beneficiary address on Astar
7676
network: undefined,
7777
id: idBenef,
78-
}),
78+
})
7979
),
8080
}),
8181
assets: XcmVersionedAssets.V3([
@@ -110,7 +110,7 @@ await new Promise((resolve) => setTimeout(resolve, 20000));
110110
// Fetch asset balance of recipient (Dave) after transaction
111111
assetMetadata = await astarApi.query.Assets.Account.getValue(
112112
polkadotAssetId,
113-
daveAddress,
113+
daveAddress
114114
);
115115
console.log('Asset balance after tx:', assetMetadata?.balance ?? 0);
116116

.snippets/code/tutorials/polkadot-sdk/testing/spawn-basic-chain/connect-to-alice-01.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function main() {
1212
]);
1313

1414
console.log(
15-
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`,
15+
`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`
1616
);
1717
}
1818

69.1 KB
Loading

infrastructure/running-a-node/.pages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ nav:
33
- index.md
44
- 'Set Up a Full Node': setup-full-node.md
55
- 'Set Up a Bootnode': setup-bootnode.md
6-
# - 'Common Node Flags': common-node-flags.md
6+
- 'Set Up Secure Websocket': setup-secure-wss.md

0 commit comments

Comments
 (0)