1
votes

I have created a Cloud service with 2 web roles (one is the "public" site, and the other is the "admin backend").

I deployed the solution in azure, and the cloud service with the web roles were created. I can access both sites using:

FrontEnd

http://my-app.cloudapp.net:80/

BackEnd

http://my-app.cloudapp.net:8080/

Here is the problem: I would like to access the backend as a subdomain of the main site. I tried to update the DNS (GoDaddy) playing with the CNAME, but I have not been able to find a solution since it seems that I cannot use port numbers. One solution could be to create 2 Cloud Services, each one with just one web role (of course, both using port 80); but due to business requirements it's not a good idea. Any ideas?

FWIW, this is what I would like:

FrontEnd

http://my-app.com

BackEnd

http://dashboard.my-app.com
2

2 Answers

1
votes

You should be able to add two CNAMES or A-records with your hostnames, pointing to the same site/port. You can then use URL rewriting to map the hostnames to different directories, something like (the untested);

<rewrite>
  <rules>
    <rule name="Dashboard rewrite" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^dashboard\.my-app\.com$" />
      </conditions>
      <action type="Rewrite" url="http://my-app.com/dashboard/{R:0}" />        
    </rule>
  </rules>
</rewrite>

This will/should rewrite the access to http://dashboard.my-app.com/test.aspx to http://my-app.com/dashboard/test.aspx, giving the impression to the browser of being two separate applications.

0
votes

With DNS CNAME you can only point from one hostname to another. Port numbers are a totally different item.

You can install an HTTP reverse proxy server to forward the requests to the proper cloud service. (e.g. HAProxy, nginx, IIS ARR etc.). There are some solutions in this SO question: How do I create a reverse proxy that runs in Azure?