Friday 9 June 2017

Angular 4 server side rendering on NGINX

I'm looking for some guidance deploying my Angular 4 Universal app. I've got a proper production build on my localhost running an express server for server side rending. I now want to run this on a production NGINX server with a reverse proxy to the app. So what I've done is upload the entire project to /var/www/html. Then I do an npm run serve and I get:

Express server listening on http://localhost:8000

Seems like all is well there. I then tried setting up a reverse proxy in /etc/nginx/sites-enabled/default file with the following code:

server {
listen 80;

server_name http://mywebsite.com;

location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

}

Visiting the website in the browser does not display the app. My questions are, is this the right approach and am I missing anything in this process. I'm new to running node.js apps in this way, so trying to wrap my head around the configuration. Thanks!



via Bennie

No comments:

Post a Comment