Skip to content

Instantly share code, notes, and snippets.

@netologist
Last active October 13, 2017 04:28
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 netologist/72d1131e9160fd87a810aa520729be09 to your computer and use it in GitHub Desktop.
Save netologist/72d1131e9160fd87a810aa520729be09 to your computer and use it in GitHub Desktop.
nginx react unsupported
FROM nginx:alpine
ADD dist/ /usr/share/nginx/html
ADD /docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
map $http_user_agent $outdated {
default 0;
"~*MSIE [1-9]\." 1;
"~*Mozilla.*Firefox/[1-9]\." 1;
"~*Mozilla.*Firefox/[0-2][0-9]\." 1;
"~*Mozilla.*Firefox/3[0-1]\." 1;
"~*Opera.*Version/[0-9]\." 1;
"~*Opera.*Version/[0-1][0-9]\." 1;
"~*Opera.*Version/2[0-1]\." 1;
"~*AppleWebKit.*Version/[0-6]\..*Safari" 1;
"~*Chrome/[0-9]\." 1;
"~*Chrome/[0-2][0-9]\." 1;
"~*Chrome/3[0-3]\." 1;
}
server {
listen 80;
server_name localhost;
# Security Headers
server_tokens off;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
# Optimization
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
root /usr/share/nginx/html;
location ~ (?:.+\/)((?:.+)\.(?:.+)) {
# $1 is the filename
try_files $uri /$1 /css/$1 =404;
}
location / {
if ($outdated = 1){
rewrite ^ /unsupported.html break;
}
try_files $uri /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment