|
1 | 1 | # Local Reverse Proxy |
2 | 2 | The reverse proxy server for the local environment that can help to run several docker projects locally via the 80 port. |
3 | 3 |
|
| 4 | +## How to use it |
| 5 | +1. [Download and Install Go](https://go.dev/dl/) |
| 6 | +2. Clone this repo where you want. |
| 7 | +3. Configure ports for your docker projects: |
| 8 | + - Create `docker-compose.override.yml` in a project. |
| 9 | + - Add there apache or nginx service and change a port. Because by default most of projects uses 80 or 443 ports. |
| 10 | + Yaml should look like this: |
| 11 | + ```yaml |
| 12 | + services: |
| 13 | + nginx: |
| 14 | + ports: !override # helps to reset ports. Works only on the latest version of docker-compose |
| 15 | + - "8080:80" # Now set up new external port `8080` |
| 16 | + ``` |
| 17 | + - Recreate docker containers into your project directory. |
| 18 | + ```bash |
| 19 | + docker-compose up -d --force-recreate |
| 20 | + ``` |
| 21 | + - Do the same steps for another docker project but use another port, as example `8090`. |
| 22 | + **Remember one port for one service/device!** |
| 23 | +> [!NOTE] |
| 24 | +> Your 2 and more projects have to run and work without any issues, if not check that external ports be unique. |
| 25 | +
|
| 26 | +4. Go to the directory of cloned `localreverseproxy` repository. |
| 27 | +5. Add your docker services into `services.json` file. Where: |
| 28 | + - `Key` is local domain address. |
| 29 | + - `Value` is URL:Port of docker service. Use `http://localhost:<your_service_port>` |
| 30 | + |
| 31 | +> [!NOTE] |
| 32 | +> You can use simple regexp in `Key` fields of `services.json` file. |
| 33 | +> To have a mask, like: `*.local`. |
| 34 | +
|
| 35 | +> [!NOTE] |
| 36 | +> If you change the `services.json` file you don't need to compile app again. It is read in runtime. |
| 37 | +
|
| 38 | +> [!NOTE] |
| 39 | +> Don't forget add domains into your hosts file. |
| 40 | +
|
| 41 | +6. Let's compile Go app |
| 42 | +```bash |
| 43 | +go mod tidy |
| 44 | +go build |
| 45 | +``` |
| 46 | +7. Run Local Reverse Proxy |
| 47 | +```bash |
| 48 | +./localreverseproxy |
| 49 | +``` |
| 50 | +If everything ok you will see in a console |
| 51 | +```bash |
| 52 | +Reverse proxy is started. |
| 53 | +``` |
| 54 | + |
| 55 | +--- |
| 56 | + |
4 | 57 | ## Roadmap |
5 | 58 | - [x] Configure routing via `json`. |
6 | 59 | - [x] Implement reverse-proxy functionality. |
7 | | -- [ ] Add documentation how to use it. |
| 60 | +- [x] Add documentation how to use it. |
8 | 61 | - [x] Show error if port is busy. |
| 62 | +- [x] Add requests logging in console. |
| 63 | +- [ ] Add service response logging in console. |
9 | 64 | - [ ] Add supporting url paths. |
10 | 65 | - [ ] Add supporting https. |
0 commit comments