Slow TTFB (60 Seconds) on Nginx reverse proxy with AngularHow to set up Nginx as a caching reverse proxy?Help...

Implement the Thanos sorting algorithm

Is it appropriate to ask a job candidate if we can record their interview?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Two monoidal structures and copowering

Is the destination of a commercial flight important for the pilot?

Would a high gravity rocky planet be guaranteed to have an atmosphere?

How does buying out courses with grant money work?

Proof of work - lottery approach

System.debug(JSON.Serialize(o)) Not longer shows full string

How do I rename a Linux host without needing to reboot for the rename to take effect?

How does the UK government determine the size of a mandate?

How to safely derail a train during transit?

How to run a prison with the smallest amount of guards?

Applicability of Single Responsibility Principle

Sort a list by elements of another list

How can a function with a hole (removable discontinuity) equal a function with no hole?

Is there a good way to store credentials outside of a password manager?

What can we do to stop prior company from asking us questions?

Is there a korbon needed for conversion?

Lay out the Carpet

Why escape if the_content isnt?

Inappropriate reference requests from Journal reviewers

Term for the "extreme-extension" version of a straw man fallacy?

Tiptoe or tiphoof? Adjusting words to better fit fantasy races



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


How to set up Nginx as a caching reverse proxy?Help needed setting up nginx to serve static filesConfigure php5-fpm for many concurrent usersNginx reverse proxy + URL rewriteNginx gives 504 Gateway Time-out once moved to liveHow to tell: Is it nginx or PHP-cgi which is slower?Change Nginx document root from /usr/share/nginx to /etc/nginx403 Forbidden nginx (nginx/1.8.0)nginx configuration troubleUniversal HTTPS to HTTP reverse proxy using nginx













0















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;
}
}









share|improve this question














bumped to the homepage by Community 11 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

    – Brennen Smith
    Mar 2 '18 at 21:49











  • I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

    – ServerAmateur
    Mar 2 '18 at 22:18
















0















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;
}
}









share|improve this question














bumped to the homepage by Community 11 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

    – Brennen Smith
    Mar 2 '18 at 21:49











  • I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

    – ServerAmateur
    Mar 2 '18 at 22:18














0












0








0








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;
}
}









share|improve this question














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;
}
}






nginx reverse-proxy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 2 '18 at 20:43









ServerAmateurServerAmateur

1113




1113





bumped to the homepage by Community 11 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 11 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

    – Brennen Smith
    Mar 2 '18 at 21:49











  • I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

    – ServerAmateur
    Mar 2 '18 at 22:18



















  • Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

    – Brennen Smith
    Mar 2 '18 at 21:49











  • I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

    – ServerAmateur
    Mar 2 '18 at 22:18

















Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

– Brennen Smith
Mar 2 '18 at 21:49





Can you provide any information about the backing server at localhost:1337? Most likely, that's the slow server.

– Brennen Smith
Mar 2 '18 at 21:49













I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

– ServerAmateur
Mar 2 '18 at 22:18





I'm not sure what you would mean by backing server, is it not the same as the server in which I have this configs? If you could direct me as to where to find the info, I could get back to you

– ServerAmateur
Mar 2 '18 at 22:18










1 Answer
1






active

oldest

votes


















0














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.






share|improve this answer
























  • Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

    – ServerAmateur
    Mar 4 '18 at 17:05











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f899739%2fslow-ttfb-60-seconds-on-nginx-reverse-proxy-with-angular%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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.






share|improve this answer
























  • Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

    – ServerAmateur
    Mar 4 '18 at 17:05
















0














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.






share|improve this answer
























  • Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

    – ServerAmateur
    Mar 4 '18 at 17:05














0












0








0







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 3 '18 at 0:09









Brennen SmithBrennen Smith

1,280311




1,280311













  • Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

    – ServerAmateur
    Mar 4 '18 at 17:05



















  • Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

    – ServerAmateur
    Mar 4 '18 at 17:05

















Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

– ServerAmateur
Mar 4 '18 at 17:05





Unfortunately, the server isn't structured to work like this. With said config, you will be routed to the homepage effectively but the app will be unable to server any other pages! The reverse proxy is in place to route requests through a js script which serves the correct pages of the app.

– ServerAmateur
Mar 4 '18 at 17:05


















draft saved

draft discarded




















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f899739%2fslow-ttfb-60-seconds-on-nginx-reverse-proxy-with-angular%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

Список ссавців Італії Природоохоронні статуси | Список |...

Українські прізвища Зміст Історичні відомості |...