I'm running Apache Answer using Docker Compose.
How do I get Answer to be running on the standard HTTP port so I don’t have to type the 9080 into the browser?
I'm running Apache Answer using Docker Compose.
How do I get Answer to be running on the standard HTTP port so I don’t have to type the 9080 into the browser?
To get Apache Answer running on the standard HTTP port (port 80), you need to adjust your Docker Compose configuration and ensure no other services are conflicting on port 80. Here’s how you can do it:
Update Docker Compose Configuration
Modify your docker-compose.yaml
file to map port 80 on the host to port 80 on the container. Update the ports
section like this:
version: "3"
services:
answer:
image: apache/answer
ports:
- '80:80'
restart: on-failure
volumes:
- answer-data:/data
volumes:
answer-data:
Restart Docker Compose Services
Bring down the current services and start them again with the updated configuration:
docker-compose -p answer down
docker-compose -p answer up -d
Check for Port Conflicts
Ensure no other services are using port 80. You can check this with the following command:
sudo lsof -i -P -n | grep LISTEN
If another service is using port 80 (e.g., Nginx, Apache), you need to stop it or reconfigure it to use a different port.
Configure Firewall
Ensure your firewall allows traffic on port 80. For UFW (Uncomplicated Firewall):
sudo ufw allow 80/tcp
If you are using DigitalOcean's cloud firewall, make sure it has rules allowing traffic on port 80.
If you prefer to keep Docker Compose running on port 9080 internally but want to access it on port 80 externally, you can set up Nginx as a reverse proxy.
Install Nginx
sudo apt update
sudo apt install -y nginx
Configure Nginx
Create a new configuration file for your site:
sudo nano /etc/nginx/sites-available/answer
Add the following configuration:
server {
listen 80;
server_name your_domain_or_ip;
location / {
proxy_pass http://127.0.0.1:9080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable Nginx Configuration
Enable the new configuration and restart Nginx:
sudo ln -s /etc/nginx/sites-available/answer /etc/nginx/sites-enabled/
sudo systemctl restart nginx
By following these steps, you can access Apache Answer on the standard HTTP port (port 80) without having to specify port 9080 in the browser URL.