server {
  listen 80;
  server_name {{ appsmith_public_url | urlsplit('hostname') }};
  include /etc/nginx/ansible_conf.d/acme.inc;
  root {{ appsmith_root_dir }}/client;
  client_max_body_size 10M;

  if ($request_method !~ ^(GET|POST|HEAD|PUT|DELETE|PATCH)$ ) {
    return 405;
  }

  # Send info about the original request to the backend
  proxy_set_header X-Forwarded-For "$proxy_add_x_forwarded_for";
  proxy_set_header X-Real-IP "$remote_addr";
  proxy_set_header X-Forwarded-Proto "$scheme";
  proxy_set_header X-Forwarded-Host "$host";
  proxy_set_header Host "$host";

  location / {
    try_files $uri /index.html =404;
  }
  location /f {
    proxy_pass https://cdn.optimizely.com/;
  }
  location /api {
    proxy_pass http://127.0.0.1:{{ appsmith_server_port }};
  }
  location /oauth2 {
    proxy_pass http://127.0.0.1:{{ appsmith_server_port }};
  }
  location /login {
    proxy_pass http://127.0.0.1:{{ appsmith_server_port }};
  }
}
