merge from master

This commit is contained in:
softsimon 2020-07-05 23:24:06 +07:00
commit 4ff9663812
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7
5 changed files with 55 additions and 44 deletions

View file

@ -73,7 +73,7 @@
</tr> </tr>
<tr> <tr>
<td style="border: 0;"> <td style="border: 0;">
<input class="form-control" type="text" value="wss://mempool.space/ws" readonly> <input class="form-control" type="text" value="wss://mempool.space/api/v1/ws" readonly>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
import { StateService } from './state.service'; import { StateService } from './state.service';
import { BisqTransaction, BisqBlock } from '../interfaces/bisq.interfaces'; import { BisqTransaction, BisqBlock } from '../interfaces/bisq.interfaces';
const API_BASE_URL = '/api{network}/v1'; const API_BASE_URL = '{network}/api/v1';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'

View file

@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { Block, Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface'; import { Block, Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface';
import { StateService } from './state.service'; import { StateService } from './state.service';
const API_BASE_URL = document.location.protocol + '//' + document.location.hostname + ':' + document.location.port + '/electrs'; const API_BASE_URL = '{network}/api';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -16,12 +16,12 @@ export class ElectrsApiService {
private httpClient: HttpClient, private httpClient: HttpClient,
private stateService: StateService, private stateService: StateService,
) { ) {
this.apiBaseUrl = API_BASE_URL; this.apiBaseUrl = API_BASE_URL.replace('{network}', '');
this.stateService.networkChanged$.subscribe((network) => { this.stateService.networkChanged$.subscribe((network) => {
if (network === 'bisq') { if (network === 'bisq') {
network = ''; network = '';
} }
this.apiBaseUrl = API_BASE_URL + '/' + network; this.apiBaseUrl = API_BASE_URL.replace('{network}', network ? '/' + network : '');
}); });
} }

View file

@ -6,7 +6,7 @@ import { Block, Transaction } from '../interfaces/electrs.interface';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
const WEB_SOCKET_PROTOCOL = (document.location.protocol === 'https:') ? 'wss:' : 'ws:'; const WEB_SOCKET_PROTOCOL = (document.location.protocol === 'https:') ? 'wss:' : 'ws:';
const WEB_SOCKET_URL = WEB_SOCKET_PROTOCOL + '//' + document.location.hostname + ':' + document.location.port + '/ws'; const WEB_SOCKET_URL = WEB_SOCKET_PROTOCOL + '//' + document.location.hostname + ':' + document.location.port + '{network}/api/v1/ws';
const OFFLINE_RETRY_AFTER_MS = 10000; const OFFLINE_RETRY_AFTER_MS = 10000;
const OFFLINE_PING_CHECK_AFTER_MS = 30000; const OFFLINE_PING_CHECK_AFTER_MS = 30000;
@ -30,7 +30,7 @@ export class WebsocketService {
private stateService: StateService, private stateService: StateService,
) { ) {
this.network = this.stateService.network === 'bisq' ? '' : this.stateService.network; this.network = this.stateService.network === 'bisq' ? '' : this.stateService.network;
this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL + '/' + this.network); this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL.replace('{network}', this.network ? '/' + this.network : ''));
this.startSubscription(); this.startSubscription();
this.stateService.networkChanged$.subscribe((network) => { this.stateService.networkChanged$.subscribe((network) => {
@ -48,7 +48,7 @@ export class WebsocketService {
this.websocketSubject.complete(); this.websocketSubject.complete();
this.subscription.unsubscribe(); this.subscription.unsubscribe();
this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL + '/' + network); this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL.replace('{network}', this.network ? '/' + this.network : ''));
this.startSubscription(); this.startSubscription();
}); });

View file

@ -141,6 +141,25 @@ http {
index index.html index.htm index.nginx-debian.html; index index.html index.htm index.nginx-debian.html;
server_name mempool.space; # managed by Certbot server_name mempool.space; # managed by Certbot
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
set $frameOptions "DENY";
set $contentSecurityPolicy "frame-ancestors 'none'";
if ($http_referer ~ ^https://mempool.space/)
{
set $frameOptions "ALLOW-FROM https://mempool.space";
set $contentSecurityPolicy "frame-ancestors https://mempool.space";
}
if ($http_referer ~ ^https://wiz.biz/)
{
set $frameOptions "ALLOW-FROM https://wiz.biz";
set $contentSecurityPolicy "frame-ancestors https://wiz.biz";
}
add_header X-Frame-Options $frameOptions;
add_header Content-Security-Policy $contentSecurityPolicy;
add_header Link "<https://mempool.space$request_uri>; rel=\"canonical\"";
location / { location / {
try_files $uri $uri/ /index.html =404; try_files $uri $uri/ /index.html =404;
} }
@ -153,64 +172,56 @@ http {
proxy_pass http://127.0.0.1:2222/; proxy_pass http://127.0.0.1:2222/;
} }
location /api { location /api/v1/ws {
proxy_pass http://127.0.0.1:8999/api;
}
location /api/mainnet {
proxy_pass http://127.0.0.1:8999/api;
}
location /api/liquid {
proxy_pass http://127.0.0.1:8998/api;
}
location /api/testnet {
proxy_pass http://127.0.0.1:8997/api;
}
location /electrs/ {
proxy_pass http://[::1]:3000/;
}
location /electrs/mainnet/ {
proxy_pass http://[::1]:3000/;
}
location /electrs/liquid/ {
proxy_pass http://[::1]:3001/;
}
location /electrs/testnet/ {
proxy_pass http://[::1]:3002/;
}
location /ws {
proxy_pass http://127.0.0.1:8999/; proxy_pass http://127.0.0.1:8999/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
} }
location /api/v1 {
proxy_pass http://127.0.0.1:8999/api/v1;
}
location /api/ {
proxy_pass http://[::1]:3000/;
}
location /ws/mainnet { location /mainnet/api/v1/ws {
proxy_pass http://127.0.0.1:8999/; proxy_pass http://127.0.0.1:8999/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
} }
location /mainnet/api/v1 {
proxy_pass http://127.0.0.1:8999/api/v1;
}
location /mainnet/api/ {
proxy_pass http://[::1]:3000/;
}
location /ws/liquid { location /liquid/api/v1/ws {
proxy_pass http://127.0.0.1:8998/; proxy_pass http://127.0.0.1:8998/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
} }
location /liquid/api/v1 {
proxy_pass http://127.0.0.1:8998/api/v1;
}
location /liquid/api/ {
proxy_pass http://[::1]:3001/;
}
location /ws/testnet { location /testnet/api/v1/ws {
proxy_pass http://127.0.0.1:8997/; proxy_pass http://127.0.0.1:8997/;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
} }
location /testnet/api/v1 {
proxy_pass http://127.0.0.1:8997/api/v1;
}
location /testnet/api/ {
proxy_pass http://[::1]:3002/;
}
} }
} }