upstream waifu2x {
        server localhost:8812;
}
map $http_accept_language $lang {
  default en;
  ~ja ja;
  ~en en;
  ~ru ru;
}
server {
       # listen 80 default_server; 
       server_name waifu2x.udp.jp; # fill your domain
       
       access_log	/var/log/nginx/waifu2x.access.log;
       
       root   /home/ubuntu/waifu2x/assets;
       try_files $uri $uri/index.$lang.html $uri/index.html @api;

       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP  $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

       location ~ ^/(apple-touch-icon|browserconfig|favicon|mstile)(.*)\.(png|xml|ico)$ {
          return 204;
       }
       location @api {
          proxy_pass http://waifu2x;
       }
}
