1

My scenario is as follows.

I have my website.azurewebsites.net main site which redirects to https://website.dk (I bought this domain) and created another deployment slot called website-dev.azurewebsites.net. However when I want to visit the 'dev' one it is still being redirected to https://website.dk which has the changes from website.azurewebsites.net.

How can I access website-dev.azurewebsites.net without being redirected to the main one?

Edit: Maybe it is the redirect in the web.config file, but I have commented out the redirect part and published?

crystyxn
  • 1,411
  • 4
  • 27
  • 59

3 Answers3

1

Commenting out the redirection is not a good practice as it could cause issues if you swap your dev environment to your production environment and you forget to add the redirection again.

You should add conditions to your rules so they are only executed in the production environment. I recommend you to follow the steps described in https://gist.github.com/alindgren/999c542a6625ddfb41f1b0293878dcad

Francisco Goldenstein
  • 13,299
  • 7
  • 58
  • 74
0

I have found the solution, turns out I had to comment the entire <rewrite> block in the web.config.

<!--<rewrite>
  <rules>
    <rule name="Force HTTPS" enabled="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://website.dk/" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>-->
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
crystyxn
  • 1,411
  • 4
  • 27
  • 59
-1

For me, this symptom occurred due to the load balancer routing rules with the new Deployment slots (Preview) functionality. This allow allows you to redirect a proportion of traffic from one slot (i.e., production) to other slots (i.e., staging). You can also route traffic from staging back to production, so there is a matrix of reroutings.

This configuration sends all traffic to the expected site

    TO  prod stag
FROM    
prod    100%   0%
stag      0% 100%

This is a sensible configuration for AB testing, with 5% of traffic prod going to staging, and all staging traffic going to staging

    TO  prod stag
FROM    
prod    95%    5%
stag     0%  100%

I slipped up and had this setup, with 100% of staging going to production

    TO  prod stag
FROM    
prod    100%  0%
stag    100%  0%

The UI is a little unintuitive.

To fix the problem, for each web app (production, staging, dev etc) in your web service,

  • click on "Deployment slots (Preview)"
  • set the proportion of traffic as appropriate for that web app.

If you are not doing any A/B testing or similar, you should direct 100% of traffic to that same app (i.e., 100% in the greyed box, 0% in all the others.)

There also appears to be an issue with Azure with the same symptoms as described in the question, although this was not my problem.

Azure load balancer redirects staging slots traffic to production, unable to access staging

Michael C
  • 81
  • 4
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/21880781) – mohan08p Jan 09 '19 at 04:11
  • Expanded with the specific resolution to my problem – Michael C Jan 09 '19 at 05:10