Compare commits

19 Commits

Author SHA1 Message Date
406c9ba3c3 CURL_IMPERSONATE var now set during build 2023-05-30 23:05:53 +05:00
f7d9583c5b added container hostname 2023-05-30 23:02:04 +05:00
b07ec89213 change build image to debian base, bc alpine gay 2023-05-30 22:58:57 +05:00
7fddc087a2 i forgot it would create that folder anywar 2023-05-30 22:57:40 +05:00
39e4d3b96d lmao useless junk 2023-05-30 22:37:21 +05:00
66ce95adaa added multistage build 2023-05-30 22:34:06 +05:00
0ad15b913c added proper README.md 2023-05-30 22:33:13 +05:00
1fb4ebe218 update to new URL 2023-05-29 11:14:20 +05:00
1079dd6850 there was an attempt 2022-09-24 16:04:44 +05:00
9a9b4b3e68 readme 2022-09-24 04:40:34 +05:00
981e4d4f21 comments 2022-09-24 04:29:49 +05:00
1d9510e9df comments 2022-09-24 04:27:39 +05:00
dd6d2e13e5 apparently that was needed 2022-09-24 04:23:59 +05:00
1d2324ad0a tash removal 2022-09-24 04:22:23 +05:00
37f834b196 tash removal 2022-09-24 04:19:43 +05:00
50ef4c58d9 cargo path fix 2022-09-24 04:07:06 +05:00
108171f8be Dockerfile 2022-09-24 03:47:01 +05:00
48b11221fe Revert "fix: also relay Content-Encoding"
* even if the server sends gzip data, our proxy always sends raw text

This reverts commit c53f37406f.
2022-08-10 20:07:23 +05:30
c53f37406f fix: also relay Content-Encoding 2022-08-09 02:50:25 +05:30
6 changed files with 102 additions and 2 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
docker-compose.yml
Dockerfile
README.md

4
.gitignore vendored
View File

@ -1 +1,3 @@
/target
target/
.ash_history
.bash_history

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM rust:slim-bullseye AS build
WORKDIR /root
COPY . .
RUN apt-get update \
&& apt-get install -y pkg-config \
build-essential \
openssl \
libssl-dev
RUN cargo build --release
FROM lwthiker/curl-impersonate:0.5-chrome-slim-bullseye
WORKDIR /root
COPY --from=build /root/target/release/bml_proxy /root/
ENV CURL_IMPERSONATE=chrome110
ENV LD_PRELOAD="/usr/local/lib/libcurl-impersonate-chrome.so"
CMD /root/bml_proxy

63
README.md Normal file
View File

@ -0,0 +1,63 @@
# BML Proxy Docker
On April 1, 2022 BML enabled [Cloudflares Anti-bot](https://www.cloudflare.com/products/bot-management/) features and all the
existing scripts to interact with BML API stopped working.
This repo contains build files for a [proxy](https://git.shihaam.dev/shihaam/bml-proxy) to bypass anti-bot.
## Codebase repo:
- [https://git.shihaam.dev/shihaam/bml-proxy](https://git.shihaam.dev/shihaam/bml-proxy)
## Installation
1. [Install docker](https://docs.docker.com/engine/install/) `curl -fsSL https://get.docker.com | sudo sh`
2. Give yourself docker group and relogin.
`sudo usermod -aG docker $USER;sudo su - $USER`
3. Generate ssh key (if you havent already)
`ssh-keygen`
4. [Add your .pub key to my gitea server](https://git.shihaam.dev/user/settings/keys)
`cat ~/.ssh/id_*.pub`
5. Clone the repo `git clone git@git.shihaam.dev:shihaam/bml-proxy.git`
6. Go to cloned dir `cd bml-proxy`
7. Start the docker container `docker compose up -d`
## How to use
This docker image exposes a proxied BML API on localhost port 3030. Any and all requests to the BML API should instead be made to this proxy instead.
BML API URL = https://bankofmaldives.com.mv/internetbanking/api/ \
Docker Image URL = http://localhost:3030/api/
### Best practices on usage:
It is recommded that you use nginx reverse proxy and cloudflare proxy with this for security and compatability reasons
1. Install Nginx, Certbot, and Nginx Cerbot plugin `sudo apt install nginx python3-certbot python3-certbot-nginx` \
example nginx config: place this is in a file at "/etc/nginx/sites-enabled"
```nginx
server {
server_name SUB.DOMAIN.COM;
listen 80;
location / {
proxy_pass http://localhost:3030;
}
}
```
2. Point your sub.doman.com to server IP (its important you disable cloudflare proxy)
3. Use certbot to get SSL `sudo certbot --nginx -d sub.domain.com`
4. Enable Cloudflare to fix encoding issue.
5. Use your programs to request to request to this proxy URL instead of BML URL
#### Example
You would normally hit the following URL to retrieve today's transactions:
```
https://www.bankofmaldives.com.mv/internetbanking/api/account/{BML_ACCOUNT_NUMBER}/history/today
```
With this Docker image you will use the following:
```
https://sub.domain.com/account/{BML_ACCOUNT_NUMBER}/history/today
```
## Disclaimer
This package is no way associated with [Bank of Maldives](https://www.bankofmaldives.com.mv/).
I am not responsible for any losses incurred from the use of this package.
Use at your own risk.

10
docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: '3.5'
services:
#########################
bmlapi-proxy:
build: .
image: git.shihaam.dev/shihaam/bmlapi-proxy:latest
hostname: bmlapi-proxy
ports:
- 3030:3030
restart: always

View File

@ -11,7 +11,7 @@ use warp::{http::Method, http::Response, hyper::body::Bytes, path::FullPath, Fil
const FOR_COPY: [&'static str; 2] = ["Content-Type", "Cookie"];
const BASE: &str = "https://www.bankofmaldives.com.mv/internetbanking/api/";
const BASE: &str = "https://www.bankofmaldives.com.mv";
const ERR: &str = "{ \"code\": 407, \"message\": \"Proxy failed\" }";
fn get_base_url() -> String {