I have successfully setup Traefik under a top-level domain such as example.com, which is used as a main reverse proxy in docker-swarm with multiple containers/stacks. This way, I could automatically point traefik to subdomains received from docker containerized services, e.g. service1.example.com, service2.example.com etc.
My question is, would such a setup also work if I run traefik in a subdomain, e.g. app.example.com, where example.com is hosted on a completely separate server not managed by traefik? I want my containers to be reachable similarly in those subdomains, e.g. service1.app.example.com, service2.app.example.com, wherein subdomains (service1, service2) are managed by traefik running at app.example.com.
I know that I needed a DNS A record to point to my traefik-instance in example 1, can I do something similar with a subdomain or would this work differently?
Many thanks for hints!
This will work without a problem, as long as your domain provider doesn't restrict this.
You will have an A record with *.app and point it to the Traefik server ip
Related
I have a web application with a Vue front-end and Golang back-end.
I am trying to deploy the front-end static files on local work network.
I am serving them with http-server on a windows server connected to the network.
Rightnow if I execute
http-server -p 50
I am able to access the application by going to http://hostname:
50
However, the goal is to deploy it on
http://hostname/app
Is it possible to do it, if so what would be the approach in terms of best practices.
Note: For deployment of the Vue static files either a node server or golang server would work.
Let's start with a bit of terminology correction.
http://hostname is not really a domain. It is just a URL referring to
an unqualified host name. A domain would typically be something like
yourorgdomain.com (or .org or .edu or other such top level domains;
let's stick with .com for now). Your hostname (when fully qualified
under the domain) would be identified as hostname.yourdomain.com.
Therefore, your hostname is mapped to a subdomain. For the sake of
simplicity, if being referred from another host on the same domain
and network the domain part is implied so the network understands that and something like http://hostname just works. The mapping is somewhere
in your network configuration.
http://hostname/app is not a subdomain of http://hostname; it's just
a path (or more correctly a resource) under the same host http://hostname. A subdomain would be something like http://app.hostname http://app.hostname.yourdomain.com when fully qualified)
Now for some explanation of how these URLs work:
Consider the URL http://hostname:50. The http:// part is referring to the protocol and :50 part at the end to the port number. By default http uses port 80 (https uses 443). So if you configure your web server to serve on port 80, the :50 part is redundant.
Now you just need to organize your website content such that it is available at http://hostname/app URL. The simplest way to do this for static sites is to host your content under the /app/... directory relative to where your site root is mapped to. So if your web server is serving the directory .../public on http://hostname, just move your content to .../public/app like you do for file paths. That's all
Caveats
However, if you truly want to host your app under a subdomain like http://app.hostname/ then that's a whole different story, but in brief, the lowest level subdomain being referred to (app) has to be mapped to a host and the intermediate subdomain can't be a host, just a subnet. You can't have further subdomains under a host. That's why typically websites addresses refer to http://www.example.com where the www is mapped to the host actually running the website
All of this ignores how reverse proxies and load balancers work and pretend to exhibit this above behavior but that another long story for another day.
I'm new to Caddy server but their website looked promising. I want to use it as a reverse proxy for the websites that are hosted on other servers. So, I have 2 websites; a Wiki and a photo gallery, that needs to be hosted outside of my local network.
Caddyfile
My Caddyfile is pretty straight forward:
coppery.<my domain name> {
proxy / http://192.168.1.66:80 {
transparent
}
}
wiki.<my domain name> {
proxy / http://192.168.1.88:8080 {
transparent
}
}
When I first started caddy I saw some HTTPS stuff with lets encrypt but that was succesful so now when I start it I get this output:
root#caddy:~# caddy
Activating privacy features... done.
Serving HTTPS on port 443
https://coppery.<my domain name>
https://wiki.<my domain name>
Serving HTTP on port 80
http://coppery.<my domain name>
http://wiki.<my domain name>
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with `ulimit -n 8192`.
I think for now I can dismiss the warning, I might solve that in the future but this is not a production environment anyway.
Portforwarding and DNS
I configured the domain names to resolve to my IP address (this already worked) and when I ping the domain names, they resolve the IP address correctly.
When I access the IP-addresses directly from my local network it works, I get the websites I expect. So I added some configuration on my router and port forwarded port 80 and 443 to the local IP address of the machine hosting the Caddy server.
Now when I try to access coppery.<my domain name> on either HTTP or HTTPS it's not showing anything.
So my only guess is that there is something wrong with the Caddyfile configuration but it's a realy simple case and all I've done is using the examples I found online. Which don't seem to work.
So the question is: What am I missing to make this work as intended?
The problem was the DNS. Once I configured the domain names in my local host file it worked. So the configuration in my question is all correct.
I am having stand alone Linux Centos server with Static IP. I am running two tomcat application http://IP:8080/sampleapp, http://IP:8090/myapp. i can access that both application from internet.
i bought domain from ipage.com. now i wanted to map http://sampleapp.com to http://IP:8080/sampleapp and http://myapp.com to http://IP:8090/myapp.
I don't want to add another apache layer to forward port.
How can i map..? please help me
You can give a redirection in your ipage.com DNS setting which redirects your domain to your static IP.
But I would like to suggest you can run on port 80 to just make your link prettier.
Your requirement is not very clear. However you can deploy both apps to the same port, like 80, and then use Tomcat virtual host to achieve what you need: https://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html
I have a domain with multiple active users with several applications hosting on it.
Domain: www.domain.com and running on server IP: XXX.XXX.XXX.1
I want to run www.domain.com/business on server IP: XXX.XXX.XXX.2
and similarly to run www.domain.com/hosting on server IP: XXX.XXX.XXX.3
It is very similar to Google scenario:
www.google.com runs on XXX.XXX.173.1 - XXX.XXX.185.1
www.google.com/+dinesh on XXX.XXX.186.1 -XXX.XXX.187.1
I have seen a lot of articles to manage DNS and virtual entries but unable to get correct answer.
Another way to do this is to make the host portions slightly different, i.e.:
business.domain.com/business
hosting.domain.com/hosting
You would then use these links where you are currently putting www.domain.com/business and www.domain.com/hosting. It's then a simple matter to have those different hostnames point at different addresses.
In general, it's not possible to have URLs with the same host point to different IP addresses on the basis of the stuff after the hostname. I cannot seem to verify your Google example (from where I'm looking, they both go to the same set of addresses). If you've more information on how you determined those addresses, please post that and maybe something else can be suggested.
You can manage it through Load balance rather than run on different server
Please use a reverse proxy in front of the application servers.
Consider using nginx or Apache Httpd.
These can be configured to route (technically proxy) to the desired app servers by inspecting the context path in URL.
If you choose to use nginx, see this post on how to configure nginx for such a use case.
Nginx configuration page for additional details: config
I have a server that runs different websites on different ports. All of them (but one) are Apache servers and thanks to webmin, I managed to have, for instance, example.com point to 123.123.123.123:80 and example.fr to 123.123.123.123:8000, somehow automatically
I am now running a nodejs server on the same machine, so the 80, 8000, and many other ports are already taken. My nodejs listens on 8008. I have another domain name, say example.org, and I want it to point to my nodejs website, but I simply don't know how to do that! I have updated the DNS and everything is pointing to 123.123.123.123 (my server's IP). I want to avoid using an ugly example.org:8008/ for everything on this node server. How can I make it point implicitly to the 8008 port?? I must add that I cannot afford to take down the apache servers ;)
DNS only provides name to ip address mapping. It cannot handle ports. What you can do instead is to set up a proxy server listening on port 80. The proxy server can then return data based on the host header.
Your best option is to just redirect the request from Apache. Otherwise you can use a reverse proxy like Nginx. Also, you can write a lightweight proxy in node... check out this page