
 server {
    listen 80;
    server_name {{ custom_domain }};
    client_max_body_size 100m;

    gzip on;

    root /var/www/appsmith;
    index index.html index.htm;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;

    location / {
        try_files $uri /index.html =404;

        sub_filter __APPSMITH_SENTRY_DSN__ '{{ sentry_dns }}';
        sub_filter __APPSMITH_SMART_LOOK_ID__ '{{ smart_look_id }}';
        sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '{{ google_client_id }}';
        sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '{{ github_client_id }}';
        sub_filter __APPSMITH_DISABLE_TELEMETRY__ '{{ disable_telemetry }}';
        sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '{{ marketplace_enabled }}';
        sub_filter __APPSMITH_SEGMENT_KEY__ '{{ segment_key }}';
        sub_filter __APPSMITH_OPTIMIZELY_KEY__ '{{ segment_key }}';
        sub_filter __APPSMITH_ALGOLIA_API_ID__ '{{ algolia_api_id }}';
        sub_filter __APPSMITH_ALGOLIA_SEARCH_INDEX_NAME__ '{{ algolia_search_index_name }}';
        sub_filter __APPSMITH_ALGOLIA_API_KEY__ '{{ algolia_api_key }}';
        sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '{{ client_log_level }}';
        sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '{{ google_maps_api_key }}';
        sub_filter __APPSMITH_TNC_PP__ '{{ tnc_pp }}';
        sub_filter __APPSMITH_VERSION_ID__ '{{ version_id }}';
        sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '{{ version_release_date }}';
        sub_filter __APPSMITH_INTERCOM_APP_ID__ '{{ intercom_app_id }}';
        sub_filter __APPSMITH_MAIL_ENABLED__ '{{ mail_enabled }}';
        sub_filter __APPSMITH_RECAPTCHA_SITE_KEY__ '{{ google_recaptcha_site_key }}';
        sub_filter __APPSMITH_RECAPTCHA_SECRET_KEY__ '{{ google_recaptcha_secrete_key }}';
        sub_filter __APPSMITH_RECAPTCHA_ENABLED__ '{{ google_recaptcha_enabled }}';
        sub_filter __APPSMITH_DISABLE_INTERCOM__ '{{ disable_intercom }}';
    }

    location /f {
       proxy_pass https://cdn.optimizely.com/;
    }

    location /api {
        proxy_pass http://appsmith-internal-server:8080;
    }

    location /oauth2 {
        proxy_pass http://appsmith-internal-server:8080;
    }

    location /login {
        proxy_pass http://appsmith-internal-server:8080;
    }
 }

{{ ssl_cmt }} server {
{{ ssl_cmt }}    listen 443 ssl;
{{ ssl_cmt }}    server_name {{ custom_domain }};

{{ ssl_cmt }}    ssl_certificate /etc/letsencrypt/live/{{ custom_domain }}/fullchain.pem;
{{ ssl_cmt }}    ssl_certificate_key /etc/letsencrypt/live/{{ custom_domain }}/privkey.pem;

{{ ssl_cmt }}    include /etc/letsencrypt/options-ssl-nginx.conf;
{{ ssl_cmt }}    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

{{ ssl_cmt }}    proxy_set_header X-Forwarded-Proto $scheme;
{{ ssl_cmt }}    proxy_set_header X-Forwarded-Host $host;

{{ ssl_cmt }}    root /var/www/appsmith;
{{ ssl_cmt }}    index index.html index.htm;

{{ ssl_cmt }}    location / {
{{ ssl_cmt }}        try_files $uri /index.html =404;

{{ ssl_cmt }}        sub_filter __APPSMITH_SENTRY_DSN__ '{{ sentry_dns }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_SMART_LOOK_ID__ '{{ smart_look_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '{{ google_client_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '{{ github_client_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_DISABLE_TELEMETRY__ '{{ disable_telemetry }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '{{ marketplace_enabled }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_SEGMENT_KEY__ '{{ segment_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_OPTIMIZELY_KEY__ '{{ segment_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_ALGOLIA_API_ID__ '{{ algolia_api_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_ALGOLIA_SEARCH_INDEX_NAME__ '{{ algolia_search_index_name }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_ALGOLIA_API_KEY__ '{{ algolia_api_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '{{ client_log_level }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '{{ google_maps_api_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_TNC_PP__ '{{ tnc_pp }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_VERSION_ID__ '{{ version_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '{{ version_release_date }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_INTERCOM_APP_ID__ '{{ intercom_app_id }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_MAIL_ENABLED__ '{{ mail_enabled }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_RECAPTCHA_SITE_KEY__ '{{ google_recaptcha_site_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_RECAPTCHA_SECRET_KEY__ '{{ google_recaptcha_secrete_key }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_RECAPTCHA_ENABLED__ '{{ google_recaptcha_enabled }}';
{{ ssl_cmt }}        sub_filter __APPSMITH_DISABLE_INTERCOM__ '{{ disable_intercom }}';
{{ ssl_cmt }}    }

{{ ssl_cmt }}    location /f {
{{ ssl_cmt }}       proxy_pass https://cdn.optimizely.com/;
{{ ssl_cmt }}    }

{{ ssl_cmt }}    location /api {
{{ ssl_cmt }}        proxy_pass http://appsmith-internal-server:8080;
{{ ssl_cmt }}    }

{{ ssl_cmt }}    location /oauth2 {
{{ ssl_cmt }}        proxy_pass http://appsmith-internal-server:8080;
{{ ssl_cmt }}    }

{{ ssl_cmt }}    location /login {
{{ ssl_cmt }}        proxy_pass http://appsmith-internal-server:8080;
{{ ssl_cmt }}    }

{{ ssl_cmt }} }
