janoist1 / universal-react-redux-starter-kit

Get started with React, Redux, and React-Router! - With universal rendering!
MIT License
63 stars 9 forks source link

How to serve the app by nginx? #3

Closed kuatro closed 7 years ago

kuatro commented 8 years ago

Hey! Everything works. Now I looking for some way to serve the app through Nginx. Which is the best way to start and daemonize babel-node process in production?

janoist1 commented 8 years ago

Hi! Cool. I'm just working on an improvement and once thats done I'll get back to you with the Nginx issue.

pasechnik commented 8 years ago

1/ I'm using pm2 manager to run node app with bin/start.js as starting point (maybe server-polyfl.js can be used but my file suits me better)

start.js: require('babel-register') module.exports = require('./server')

2/ created config for nginx/sites-available: upstream app_myaudit_xyz { server 127.0.0.1:3000; keepalive 80; } server {

listen 80;

    #listen [::]:80;
    #server_name ~^(www.)?myaudit.xyz$;
    server_name myaudit.xyz www.myaudit.xyz;
    root /home/app/www/dist/public;
    location / {
            try_files $uri @proxy;
    }
    location @proxy {
            proxy_pass http://app_myaudit_xyz;
            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;
    }

}

I believe this info can lead you to a working solution

bodyno commented 8 years ago

@pasechnik nice answer 👍