Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
docker-local-proxy
Advanced tools
A tool for automatically configuring Nginx and updating /etc/hosts based on Docker containers for local development environments.
docker-local-proxy
is a tool for automatically configuring Nginx and updating /etc/hosts
based on Docker containers for local development environments. It simplifies the process of setting up local proxies, allowing for dynamic HTTP and TCP port configurations.
/etc/hosts
file with container hostnames.To install docker-local-proxy
, you need to have Node.js and npm installed. Then, you can install the package via npm:
npm install --save-dev docker-local-proxy
After installing the package, you can use it via the command line:
docker-local-proxy --httpPort 80 --tcpPort 5432 --filterName "internal-proxy"
--httpPort, -p
: The HTTP ports to use in Nginx configurations, comma-separated. Default is 80
.--tcpPort, -q
: The TCP ports to use in Nginx configurations, comma-separated. Default is 5432
.--filterName, -f
: Container name filter to apply. Default is internal-proxy
.--networkOnly, -n
: Only creates the docker-local-proxy
that both the nginx proxy and your containers needs to be on. Use this if your container is complaining the network test exist.--help, -h
: Show help.Using default ports and filter name:
docker-local-proxy
docker-local-proxy --httpPort 8080,8081 --tcpPort 5433,5434 --filterName "my-proxy"
Ensure that your Docker containers are on the docker-local-proxy
network. Here is an example Docker Compose configuration:
services:
internal-proxy:
image: traefik:v2.5
labels:
- "hostname=my-custom-subdomain.localhost"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.network=cp-net"
- "--entrypoints.web.address=:80"
- "--entrypoints.tcp.address=:5432"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
your-internal-net:
docker-local-proxy:
networks:
docker-local-proxy:
external: true
your-internal-net:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/16
To add a hostname label, specify it in the labels section of your service in the Docker Compose file. The label should follow the format hostname=custom-hostname, where custom-hostname is the desired hostname. This label allows network services, like proxies or load balancers, to recognize the container by the specified hostname instead of just taking the first word up to the dash in the container name.
The tool outputs the following files to the ./generated
directory:
http_proxies.conf
: Nginx configuration for HTTP proxies.tcp_proxies.conf
: Nginx configuration for TCP proxies.Ensure the ./generated
directory exists or will be created by the tool.
The tool updates the /etc/hosts
file to include entries for the filtered Docker containers. Note that administrative privileges are required to modify /etc/hosts
. Run the tool with sudo
if necessary:
sudo docker-local-proxy --httpPort 8080,8081 --tcpPort 5433,5434 --filterName "my-proxy"
Clone the repository and install dependencies:
git clone https://github.com/yourusername/docker-local-proxy.git
cd docker-local-proxy
npm install
Compile the TypeScript code to JavaScript:
npm run build
To run the script with ts-node
:
npx ts-node src/index.ts --httpPort 8080,8081 --tcpPort 5433,5434 --filterName "my-proxy"
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the open-source community for providing the tools and libraries that made this project possible.
FAQs
A tool for automatically configuring Nginx and updating /etc/hosts based on Docker containers for local development environments.
We found that docker-local-proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.