How do I set up a password-protected proxy server with static IP on GCP using Docker?
In this guide, we will set up a password-protected proxy server with a static IP on Google Cloud Platform (GCP) using Docker and Pulumi. We will create a VM instance with a static IP address, deploy a Docker container running a proxy server, and secure it with a username and password.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as docker from "@pulumi/docker";
// Create a static IP address
const staticIp = new gcp.compute.Address("proxy-static-ip", {
addressType: "EXTERNAL",
});
// Create a GCP instance
const instance = new gcp.compute.Instance("proxy-instance", {
machineType: "f1-micro",
zone: "us-central1-a",
bootDisk: {
initializeParams: {
image: "debian-cloud/debian-9",
},
},
networkInterfaces: [{
network: "default",
accessConfigs: [{
natIp: staticIp.address,
}],
}],
metadataStartupScript: `#!/bin/bash
sudo apt-get update
sudo apt-get install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo docker run -d -p 3128:3128 -e PROXY_USERNAME=user -e PROXY_PASSWORD=pass sameersbn/squid:latest
`,
});
// Export the static IP address
export const staticIpAddress = staticIp.address;
Key Points
- Static IP Address: We created a static IP address using
gcp.compute.Address
. - GCP Instance: We set up a VM instance with a Debian image and attached the static IP address.
- Docker Container: The instance runs a Docker container with a Squid proxy server, secured with a username and password.
Summary
We successfully set up a password-protected proxy server with a static IP on GCP using Docker and Pulumi. The proxy server is deployed on a VM instance, which is configured to use a static IP address. The Docker container running the proxy server is secured with a username and password.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.