开发者

"502 Bad Gateway" with passenger

开发者 https://www.devze.com 2023-02-04 23:53 出处:网络
I am using rails(2.3.10)/passenger(2.2.15)/nginx(0.7.67) , when i run my application, it give me \"502 Bad Gateway\" and without any production log, my conf fi开发者_JAVA技巧le is :

I am using rails(2.3.10)/passenger(2.2.15)/nginx(0.7.67) , when i run my application, it give me "502 Bad Gateway" and without any production log, my conf fi开发者_JAVA技巧le is :

  1 server {
  2     listen  80;
  3     server_name  www.why.bz;
  4     root   /usr/local/apps/why/pro/public;
  5     access_log  /usr/local/apps/why/pro/log/access.log;
  6     passenger_enabled on;
  7 }

who can give me some tips, thanks!


I've done Rails deployments full-time for the last couple of years, so hopefully I can help. You've probably figured this problem out by now, but here are some questions to think about for next time:

  • Since this is a Ruby on Rails application, can you tell where the error is coming from: Nginx or Rails itself? That sounds more like a Nginx issue, but it would be good to know. A quicky peek into the Rails production.log or Nginx's error_log should elucidate this info.

  • How are you connecting to the application: web browser or command line? Is the IP and hostname set correctly (try the Linux "dig" command to verify)? Are you trying to hit http://localhost:80 ?

  • There are error log commands that nginx takes that could be configured to help you debug the issue (much like the access_log line): http://wiki.nginx.org/CoreModule#error_log

  • Lastly, verify the permissions that are set on your web files: The nginx web server needs to be able to access them. At least "read" permissions are needed.

Good luck, Harmon


change it to

listen 443;

it could be as simple as that.


It could be that your secret key base is missing for the required stage.

One thing that I sometimes forget, especially if I don't start with a staging environment and then add it later, is to add the following to my secrets.yml file:

staging:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

This is telling Rails to get the secret_key_base value from the environment variable, SECRET_KEY_BASE. You must specify this variable by placing this in your nginx configuration:

passenger_env_var SECRET_KEY_BASE yoursupersecretkeybase;

If you don't have a SECRET_KEY_BASE, you can generate one with:

bundle exec rake secret
0

精彩评论

暂无评论...
验证码 换一张
取 消