Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kramber1024/url-shortener-nginx
🟢 NGINX reverse proxy configuration for URL Shortener
https://github.com/kramber1024/url-shortener-nginx
bitly docker nginx nginx-configuration nginx-docker nginx-reverse-proxy reverse-proxy short-url url-shortener
Last synced: 7 days ago
JSON representation
🟢 NGINX reverse proxy configuration for URL Shortener
- Host: GitHub
- URL: https://github.com/kramber1024/url-shortener-nginx
- Owner: kramber1024
- License: mit
- Created: 2024-07-19T22:36:02.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T22:18:41.000Z (3 months ago)
- Last Synced: 2024-08-30T00:19:06.054Z (3 months ago)
- Topics: bitly, docker, nginx, nginx-configuration, nginx-docker, nginx-reverse-proxy, reverse-proxy, short-url, url-shortener
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URL Shortener NGINX
## Features
- 🐋 [**Docker**](https://www.docker.com/) for production.
- ✅ Tests with [**Pytest**](https://pytest.org/).> [!WARNING]
> This repository is part of a larger project that consists of multiple repositories. Using this repository on its own is not recommended, as it may not function correctly without the other components of the project. For complete functionality and proper integration, please refer to the [kramber1024/url-shortener](https://github.com/kramber1024/url-shortener).## Usage
### Requirements
- 🐋 [**Docker**](https://www.docker.com/)
> [!NOTE]
> Please ensure that Docker is properly configured and running on your system.### Installation
Clone repository:
```bash
git clone https://github.com/kramber1024/url-shortener-nginx.git
```Change directory:
```bash
cd url-shortener-nginx
```### Building an image from Dockerfile
Build the image using the following command:
```bash
docker build ./nginx -t nginx:latest
```### Running the container
Run the container using the following command:
```bash
docker run -d -p 80:80 -p 443:443 --env WEB_SERVER_HOST=host.docker.internal --env WEB_SERVER_PORT=26802 --name container-name nginx
```
Arguments:
- `-p 80:80 -p 443:443` - Expose ports 80 and 443 to the host.
- `--env WEB_SERVER_HOST=host.docker.internal` - The host of the web server. You can replace `host.docker.internal` with the IP address of the web server.
- `--env WEB_SERVER_PORT=26802` - The port of the web server. You can replace `26802` with the port of the web server.
- `--name container-name` - The name of the container. You can replace `container-name` with any name you want.### Running the container with Docker Compose
Run the container using the following command:
```bash
docker-compose up -d
```To rebuild the container, use the following command:
```bash
docker-compose up -d --build
```Edit the [**compose.yaml**](./compose.yaml) file to change launch configuration.
```yaml
name: docker-composeservices:
nginx:
container_name: nginx # Change the container namebuild:
tags:
- nginx:latest
context: ./nginx
dockerfile: Dockerfileports: # Change the ports
- "80:80"
- "443:443"environment: # Change the environment variables
- WEB_SERVER_HOST=host.docker.internal
- WEB_SERVER_PORT=26802
```## Running tests
### Requirements
- 🐋 [**Docker**](https://www.docker.com/)
- 🐍 [**Python 3.12**](https://www.python.org/)### Installation
Clone repository:
```bash
git clone https://github.com/kramber1024/url-shortener-nginx.git
```Change directory:
```bash
cd url-shortener-nginx
```### Preparing the environment
Create a virtual environment:
```bash
python -m venv venv
```Activate the virtual environment:
- On Windows:```bat
.\venv\Scripts\activate
```
- On Linux and macOS:```bash
source venv/bin/activate
```Install Poetry:
```bash
pip install poetry
```Install dependencies:
```bash
poetry install --only main --no-root
```### Running the tests
Run the tests using the following command:
```bash
pytest
```> [!NOTE]
> Make sure that Docker is running before running the tests.```bash
======================== test session starts ========================
platform win32 -- Python 3.12.2, pytest-8.2.2, pluggy-1.5.0
rootdir: C:\Users\UserName\url-shortener-nginx
configfile: pyproject.toml
collected 2 itemstests\test_build.py . [ 50%]
tests\test_run.py . [100%]=================== 2 passed in 66.27s (0:01:06) ====================
```## License
This project is licensed under the terms of the [**MIT license**](./LICENSE).