Docker on Windows server and multiple websites listening port 80 and 443 - windows

When installing ASP.NET Core apps on a windows machine, I used to install the websites within IIS, I used the bindings there to route depending on the URL to the correct web application and I used Letsencrypt to create the SSL certificates.
Now I want to start shipping my applications using Docker. The samples show, how to easily create an ASP.NET Core dockerized project, but that's where most of them end. So in the end I've got an ASP.NET application in my docker running listening on port 5000.
Are there any suggestion or resources showing how to set it up on a production system?
multiple web sites listening on the standard ports 80 and 443 and forwaring to the correct docker image
SSL certificate handling

Setup ngingx as a front end. It is world-class solution, used by top-traffic sites as a front-end for incoming requests.
Among other features it does:
Redirecting based on plenty of rules
SSL management (you can use unencrypted connections behind it)
Load balancing
It is free and available as docker image.
So, you open only ngingx outside your docker network, and make it route all your traffic inside.

Setup reverse proxy like nginx, even in IIS also you redirect to corresponding docker service having a particular port. You can fan out traffic to respective ports.
Image: https://blogs.msdn.microsoft.com/friis/2016/08/25/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world-apps/

Related

How to point shared load balancer http/https port to specific port of my Jelastic Docker container

My app listens stuff on port 8082 (or whatever one).
I want to configure shared load balancer to route all requests from 443 port (HTTPS) to this port. As far as I understand, this is done by some Jelastic magic during container creation. So far so good, everything worked fine.
But after I've updated base image for my Docker app (from openjre-152 to openjre-171 or something like this) SLB stopped to re-route traffic to my app.
Is there way to change/setup this internal configuration manually without environment re-creation?
You should use JELASTIC_EXPOSE as written in docs, however, it's not clear that your traffic will be redirected and ssl-terminated by SLB.

How can I call WEB api service fabric which deployed on azure?

I have created locally stateless WebAPI and Statefull data service with the Visual Studio 2015. It is working perfectly in the local system and website access WebAPI service by implementing http://localhost:344/api/abc/getEmployee. Then I deployed service fabric application on Azure and received client URL
http://xyz.southeastasia.cloudapp.azure.com:1900/Explorer/index.html#/abc.apptype/app/abc.app/service/abc.app%252webservices
My problem is that how can I call my WebAPI controller and action from this Azure client URL?
http://xyz.southeastasia.cloudapp.azure.com:1900/api/abc/getEmployee is not working.
Note: This url is not secure and will use by mobile and website.
You're using the wrong port to access your application. Port 19000 is a Management endpoint.
Read this to setup your API. Run your app at port 80 (if possible),
Make sure that the Azure Load Balancer has a load balancing rule for port 80 external to port 80 on the cluster nodes. More info here.
You need to configure an inbound TCP rule for the port you want to use. Typically you will map an inbound port (such as port 80) to the port that your application is listening on (e.g. 344).
In the Azure management portal, find the resource group of your deployed Service Fabric service; in it, there should be a "Load Balancer" resource. -- Click on that.
In there, you should find a pane called "Load Balancing Rules" (it's easy to look past it with the light gray icon, it's right above "Inbound NAT Rules").
Using the button at the top of the configuration blade, "Add" a rule for the port that you need opened; You should give it a meaningful name (such as HTTP or WebAPI, etc.) -- for "Port" this is the publicly facing port that you want mapped (e.g. port 80 for HTTP), and for Backend port, you can put the port that you're actually listening on (e.g. 344).
Finally, don't expect it to work right away. -- You will see a little "Updating" bar, you have to wait for that to finish.

Port forward requests from 80 to respective ports

I have many spring boot jars running in different ports. Say 9087-9090. I have a domain say
mydomain.com.
I can access mydomain.com:9087/ and use the application. Also mydomain.com:9088/ and use another application but how can i use them just like mydomain.com and still map them to desired ports. What is the technical term for this.
I use digitalocean hosting and have a Ubuntu 14.04 x64 Box. I'm running Java 7 in it.
You need a reverse proxy (a.k.az front end load balancer) with URL rewriting. I'm not sure what you hosting solution offers or permits, but you could try nginx or Apache httpd if you want something running locally. There are also service providers you might be able to use outside your host.

Reverse Proxy on Windows

I have a web server that responds to a number of different sites on port 80. Currently, IIS does the mapping to various sites via host headers, but I'd like to be able to serve other web apps on port 80 hosted in Jetty or Tomcat. IIS prevents that by grabbing all port 80 traffic.
I basically need a reverse proxy to just change the port number to something that another app stack can listen in on. I was looking into nginx but it seems to not be quite ready for prime time on Windows. Eventually I may set up a Linux box specifically for this, but for now I'm interested in a solution which will run all on the same box.
All I really need is something very light which mostly just matches hostname/port and allows rewriting of the port. Does anyone have any suggestions?
If you are running in IIS 7 or above you can use Application Request Routing for that: http://www.iis.net/download/ApplicationRequestRouting
For IIS 5-6, it looks like Apache Tomcat Connector (JK 1.2) is a clean solution. This is an IIS ISAPI filter which allows IIS to act as a reverse proxy for other web servers. It uses Apache JServ Protocol (AJP) to communicate with the app server actually serving requests. Both Tomcat and Jetty implement AJP. URLs are mapped with regex-like config to a particular AJP server instance.
Overview: http://www.iisadmin.co.uk/?p=40&page=3
IIS Config: http://tomcat.apache.org/connectors-doc/reference/iis.html
Mapping Config: http://tomcat.apache.org/connectors-doc/reference/workers.html
This ISAPI plug-in also works with IIS 7.x, but in that case the Application Request Routing (see marked answer) should be considered as it might work better with non-AJP servers.

Deploying Compojure/Sinatra Applications

What is the preferred way of deploying a compojure/sinatra applications? I have multiple sites running on the host so i can't run jetty/mongrel on port 80. How should i handle multiple sites/applications running at the same host?
Use a web server such as Apache that runs on port 80 and use virtual hosts to direct the traffic to the right app server. So basically you would run each application server (jetty/mongrel, etc.) on a different port and then in each virtual host would have a different configuration to use something like mod proxy to forward the traffic to the app server. You could use a different web server such as lighttpd or nginx. For the sinatra app you could also look at Phusion Passenger, a.k.a mod rails, a.k.a mod rack, which theoretically works with any rack app, although I've only used it with Rails.
If you look into it some more you'll find that there are various schemes for forwarding traffic to the app server from a web server, but the basic mechanism for doing this kind of thing always boils down to having a web server that listens on port 80 that uses name-based virtual hosts to then forward the traffic to the appropriate app.
I've been doing this kind of thing with various standalone servers (e.g., AllegroServe) for years. I've found the best approach to be:
Run each server on a different, non-privileged port (such as 8080)
Run pound (or Nginx etc.) on 80, configured to map requests to each application.
Pound is great, and the configurations end up very simple (unlike Nginx). It will also do SSL fronting and HTTP sanitization for you, which takes the burden off your application.
Use passenger! http://modrails.com - it is a plugin for apache and nginx that lets you (very) easily run a ruby app as a virtual host

Resources