catamphetamine / react-pages

A complete solution for building a React/Redux application: routing, page preloading, (optional) server-side rendering, asynchronous HTTP requests, document metadata, etc.
MIT License
176 stars 29 forks source link

Deployment Issues (AWS) #49

Closed weatherfordmat closed 7 years ago

weatherfordmat commented 7 years ago

The documentation by and large is great. I am struggling with finding information about deployment.Depending on my error, it might be good to add some of this info the package docs. I am trying to deploy the isomorphic package on elastic beanstalk as is. In deploying my app, I receive a "502 Bad Gateway" error.

It also has dozens of rows of error messages more or less like this: 2017/07/05 18:02:42 [error] 5215#0: *29 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.36.70, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "XXX.elasticbeanstalk.com"

        application: {
            host: 'http://XXXXX.elasticbeanstalk.com/',
            port: configuration.web.port
            // secure: true
        },

Is there something I am missing that I have to do before deployment?

catamphetamine commented 7 years ago

Does it work locally? Your host: 'http://XXXXX.elasticbeanstalk.com/', setting is wrong. It says host, not url.

weatherfordmat commented 7 years ago

Yes, it works in development and production modes locally. I had tried 127.0.0.1, localhost, etc.

catamphetamine commented 7 years ago

See my comment above. Your host: 'http://XXXXX.elasticbeanstalk.com/' setting is wrong.

weatherfordmat commented 7 years ago

So I changed this to localhost and also tried 127.0.0.1 with no luck.

catamphetamine commented 7 years ago

No, do it like host: 'XXXXX.elasticbeanstalk.com'

weatherfordmat commented 7 years ago

Thanks for the catch.

It is still not correctly working though. It is giving me the following response:

npm ERR! Linux 4.9.32-15.41.amzn1.x86_64 npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v7.6.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v7.6.0-linux-x64/lib/node_modules/npm/bin/npm-cli.js" "run" "production:client:build" npm ERR! node v7.6.0 npm ERR! npm v4.1.2 npm ERR! code ELIFECYCLE

catamphetamine commented 7 years ago

The error dump has no details

weatherfordmat commented 7 years ago

Deploy.txt no longer available.

weatherfordmat commented 7 years ago

I thought it had something to do with the version matching between node/npm and other packages, but it doesn't seem to be a result.

adailey14 commented 7 years ago

Hey @weatherfordmat, I use this repo on elastic beanstalk, but it takes some work.

The main problem is that Elastic Beanstalk only gives you one port to work with (this is similar to other services like Heroku) but this project uses multiple ports to create a separation between the outer proxying layer, the data api, and the page rendering service.

So to get it to work with one port, you have to use koa-mount instead of proxying from the web service. It can be tricky to get this to work.

weatherfordmat commented 7 years ago

Thanks adailey14! The solution seems to be a combination of (1) serving assets via koa-mount, (2) setting render: false in the application.js. file. I'm not sure if setting render to false is enough to serve the files without throwing the page rendering error. Is there anything else that comes to the top of your head that would make this work?

catamphetamine commented 7 years ago

@weatherfordmat You seem to not understand what's happening at all. The logs you provided are just a mishmash of everything you could think of and reach. My opinion is that you're taking the tasks you're not ready for at your current level of understanding things.

And also blindly posting your logs on the internets can share some secrets. Like don't be surprised if your AWS account runs low on budget the other day because of a bitcoin mining malware. I won't tell you the exact place but somewhere in this issue there are some secrets which I could use if I wanted to rule your servers like my own.

Now, for the "single port" thing. I updated the README. The "Server side" section illustrates how to run everything on a single port. https://github.com/halt-hammerzeit/react-isomorphic-render#server-side https://github.com/halt-hammerzeit/react-isomorphic-render#serving-assets-and-api There are 3 approaches described

catamphetamine commented 7 years ago

@adailey14 FYI: I made some tweaks to the library today. The former application server-side setting was renamed to proxy (I guess you didn't use it anyway) and http utility method calls now only accept relative URLs (I guess that's how everyone uses it, but in case you had some absolute URLs there you've been notified).

weatherfordmat commented 7 years ago

Thanks for guidance. I removed the txt file.