By TurboLaser
I’m working on setting up my development/deployment pipeline for my ubuntu Droplet. I used the one-click Docker Droplet and have followed the guides Install nginx, Initial Server Setup, and Secure nginx.
Where I get lost is how the Docker container and nginx/nginx server block are tied together. I have my image on Docker Hub, building on changes to my GitHub repo. That works great. I can pull the images onto my server, and run them, but I don’t know how to access them or set them up with a server block.
For example, this guide says I should be able to run a container, map it to port 8080, and access it via http://my-ip:8080 but that doesn’t work for me. Thinking 8080 probably isn’t exposed by default, I allowed it in ufw, restarted ufw, and tried again, but no luck. Trying this, and trying to figure out why it doesn’t work, and if it even should, has left me more confused.
Any input that could help clear up this last piece of the puzzle appreciated.
Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Can you share the command that you use to start your containers here?
Port 8080 is just an example for the guide, if you bind your containers on different ports, then you would need to use that specific port in your reverse proxy config.
Feel free to share the output of the docker ps command here.
Regards, Bobby
Yes, I can access containers on port 80 directly, however I was confused that I couldn’t access them over 8080 as it might have indicated a problem with my server setup. One of the per-requisites in your guide is setting up nginx with ufw.
netstat -plant | grep 8080
returns
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 81965/docker-proxy
My server block:
server {
root /var/www/myurl.com/html;
#replaced folder with {server-block}
index index.html index.htm index.nginx-debian.html;
server_name myurl.com www.myurl.com;
location / {
# try_files $uri $uri/ =404;
proxy_pass http://localhost:8080;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myurl.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myurl.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.myurl.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = myurl.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name myurl.com www.myurl.com;
return 404; # managed by Certbot
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.