I am trying to run a rails app. I followed these instructions: http://luugiathuy.com/2014/11/setup-nginx-puma-on-ubuntu/ to set up a server.
But, when I got to the end, specifically: puma -e production -d -b unix:///tmp/app_name.sock --pidfile /tmp/puma.pid
Upon running it I got the response:
Puma starting in single mode...
* Version 2.16.0 (ruby 2.1.7-p400), codename: Midwinter Nights Trance
* Min threads: 0, max threads: 16
* Environment: production
* Daemonizing...
The external IP just kept returning the nginx error:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
So, looking elsewhere, I tried:
RACK_ENV=production bundle exec puma -p 3000
And, it seemed that this did more, I got:
Puma starting in single mode...
* Version 2.15.3 (ruby 2.1.7-p400), codename: Autumn Arbor Airbrush
* Min threads: 0, max threads: 16
* Environment: production
Rails Error: Unable to access log file. Please ensure that /home/myusername/myappname/log/production.log exists and is writable (ie, make it writable for user and group: chmod 0664 /home/myusername/myappname/log/production.log). The log level has bee
n raised to WARN and the output directed to STDERR until the problem is fixed.
** [Bugsnag] Bugsnag exception handler 3.0.0 ready, api_key=#####################
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
But the external web page returned the same nginx error.
How should I proceed? It seems that things are running but puma and nginx just are not talking?
EDIT 1
I did: `sudo chmod -R 0777 /home/myunsername/appname/log/`
Then:
$RACK_ENV=production bundle exec puma -p 3000
And, now the output is below and the nginx response at the external IP remains the same.
Puma starting in single mode...
* Version 2.15.3 (ruby 2.1.7-p400), codename: Autumn Arbor Airbrush
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Now, both methods: RACK_ENV=production bundle exec puma -p 3000
and puma -e production -d -b unix:///tmp/web-app.sock --pidfile /tmp/puma.pid
create puma processes that don't seem to communicate with nginx but do not return any errors.
EDIT 2 Checking Logs
I ran:
cat log/production.log
and it returned:
I, [2016-02-02T##:##:##.###### #28802] INFO -- : ** [Bugsnag] Bugsnag exception handler 3.0.0 ready, api_key=####################
EDIT 2.5 Checking More Logs I ran:
tail -f /var/log/nginx/error.log
and it returned:
2016/02/02 11:09:52 [emerg] 28220#0: unknown directive "tream" in /etc/nginx/sites-enabled/web-appname.com:1
2016/02/02 11:10:26 [emerg] 28273#0: unknown directive "tream" in /etc/nginx/sites-enabled/web-appname.com:1
Those errors were caused a bit ago from my file missing the first 3 characters, that error has since been fixed. In conclusion: there seem to be no errors in the logs that I have listed above that give me any hints.
EDIT 3
My guess currently is that I set up my /etc/nginx/sites-available/myapp.com file incorrectly. Here is all the naming that I have used.
Currently it is named: web-app.com, the url is just the ip address, lets say https://104.199.155.166/. My application is in a folder called web-app
upstream web-app {
server unix:///tmp/web-app.sock;
}
server {
listen 80;
server_name web-app; # change to match your URL
root /home/myusername/web-app/public; # change to match your rails app public folder
location / {
proxy_pass http://web-app; # match the name of upstream directive which is defined in line 1
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
}
EDIT 4
I have made many changes to the above config file, and nothing that I do changes anything. I currently have it at what I believe to be the correct configuration. I am at a loss and would appreciate any suggestions.
Small question: if there are other users on the same VM and they may have nginx installed and configure differently, could that be causing the issues?