My word press app is working within a docker container with host port 8080 bound to the web container 80. I am able to access the app using the public IP with port 8080 (41.111.20.36:8080), but the app cannot be accessed using the only IP (41.111.20.36). Secondly, I have pointed my custom domain to digital servers and have matched the droplet and the domain name, I have even created a cname record pointing to that custom domain. But I am unable to access my application using the domain name, and I am unable to access it using the domainename:8080… I assume I should be able to access the web container with only the domain name… Am I missing something? Even inside the server, curl localhost triggers an error with the message, the server refused connection on port 80… but curl localhost:8080 works fine. Any suggestions?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
How can I do that without nginx? With .htaccess for instance?
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
Hi!
DNS only handles domain -> IP mapping. It cannot map the default port (80) to a custom port–you will have to use a reverse proxy for that. nginx is one of the most popular reverse proxies that are used to do that.
First, add a DNS record for your subdomain.
Then, install nginx:
Add a new server block:
server {
listen 80;
server_name myapp.domain.com;
location / {
proxy_pass http://localhost:8080;
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;
}
}
Finally, enable it and restart nginx:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
sudo service nginx configtest
sudo service nginx restart
You should now be able to browse to http://myapp.domain.com and see the contents of http://your droplet’s ip:8080.
If it says that there is IP not found, could this be a problem with the configuration of nginx or is this because of DNS configuration.
I can’t ping to that IP. Is it up&running?