Skip to content

Instantly share code, notes, and snippets.

@chrisns
Last active May 10, 2023 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisns/52f9fbb576128598668900917868f234 to your computer and use it in GitHub Desktop.
Save chrisns/52f9fbb576128598668900917868f234 to your computer and use it in GitHub Desktop.
flip between internet explorer mode and edge
# site needs to be in the configurable list
# follow this guide: https://learn.microsoft.com/en-us/deployedge/edge-learnmore-configurable-sites-ie-mode
http {
server {
set $ieaction '';
if ( $http_x_internetexplorermodeconfigurable = 1) {
set $ieaction "configurable+${ieaction}";
}
if ($http_x_internetexplorermodeconfigurable != 1) {
set $ieaction "nonconfigurable+${ieaction}";
}
if ( $http_user_agent ~* Trident ) {
set $ieaction "ie+${ieaction}";
}
if ( $http_user_agent !~* Trident ) {
set $ieaction "nonie+${ieaction}";
}
# if IE mode desired:
location /iemode {
if ( $ieaction = 'nonie+nonconfigurable+') {
return 402 'requires Internet Explorer mode';
}
if ( $ieaction = 'nonie+configurable+') {
add_header X-InternetExplorerMode 1;
return 302 $request_uri;
}
}
# if Edge mode desired:
location /edgemode {
if ( $ieaction = 'ie+nonconfigurable+') {
return 402 'requires non-internet explorer mode';
}
if ( $ieaction = 'ie+configurable+') {
add_header X-InternetExplorerMode 0;
return 302 $request_uri;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment