Slow TTFB (60 Seconds) on Nginx reverse proxy with Angular

The server in question is running Ubuntu 16.04 serving an Angular Application through reverse proxy. Once you connect to the primary page, not all pages take as long to load but some certainly do. Namely the https://mysite/admin page. Here as well are some missing js buttons that are not showing up on the page though all other aspects of the page are. Our site is built to route traffic with a js script but this is one of the files with a 60 second TTFB!(most files with slow TTFB are js) Though the entire application does not work without a reverse proxy, I can confirm that when it is not in effect. Additionally, it may be helpful to add that the TTFB on the site is not always 60s after the first time it is loaded however it will always be when loaded in an incognito window.

nginx.conf

user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
        worker_connections 1024;
}

http {
    proxy_cache_path /etc/nginx-cache levels=1:2 keys_zone=backcache:8m max_size=50m;                                                                                                                                                         
    proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";
    proxy_cache_valid 200 302 10m;
    proxy_cache_valid 404 1m;

    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 2 1k;

    upstream mysite {
            server [::]:1337;
     }


    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    #Looked at 12/4
    #fastcgi_buffers 8 16k;
    #fastcgi_buffer_size 32k;

    #client_max_body_size 24M;
    #client_body_buffer_size 128k;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
     application/javascript                                                                                                                                                              text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

sites-enable/default.conf

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        listen 443 ssl http2; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/mysite.net-0001/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mysite.net-0001/privkey.pem; # managed by Certbot

        root /home/admin_user/root;

        index index.html index.htm index.nginx-debian.html;

        server_name mysite.net;

        proxy_buffering on;
        proxy_buffer_size 1k;
        proxy_buffers 24 4k;
        proxy_busy_buffers_size 8k;
        proxy_max_temp_file_size 2048m;
        proxy_temp_file_write_size 32k;

        location / {
                sendfile on;
                tcp_nopush on;
                tcp_nodelay on;
                proxy_cache backcache;
                proxy_cache_bypass $http_cache_control;
                add_header X-Proxy-Cache $upstream_cache_status;

                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;

                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_pass http://localhost:1337;
    }
}

Okay, so based on your message, I think you have a copy-pasted nginx config setup for a reverse proxy.

Your config has the following stanza:

location / {
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            proxy_cache backcache;
            proxy_cache_bypass $http_cache_control;
            add_header X-Proxy-Cache $upstream_cache_status;

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;

            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass http://localhost:1337;
}

This is stating - for anything under /, send the request to localhost:1337 which from your comment, probably doesn't exist. Nginx has a 60 second timeout so I'm guessing it waiting for that long, and then falls back delivering the files at /home/admin_user/root

What you need to do is change your config to be:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        listen 443 ssl http2; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/mysite.net-0001/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mysite.net-0001/privkey.pem; # managed by Certbot

        index index.html index.htm index.nginx-debian.html;

        server_name mysite.net;

        location / {
            root /home/admin_user/root;
        }
    }

As angular is a clientside rendered application - you don't have a backing server that is being proxied. Hence, just deliver the assets in /home/admin_user/root.