Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nginx to access to the unicorn socket #10

Closed
wants to merge 1 commit into from

Conversation

joeyAghion
Copy link

I have exactly the issue described here:

https://forums.aws.amazon.com/thread.jspa?threadID=118236

Nginx can't write to the unicorn socket because of the shared/sockets directory's permissions.

Example error message:

...connect() to unix:/srv/www/myapp/shared/sockets/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: 10.158.40.157, server: myapp.com, request: "OPTIONS / HTTP/1.0", upstream: "http://unix:/srv/www/myapp/shared/sockets/unicorn.sock:/"

This proposed change expands the permissions on the sockets directory. Thanks for considering it!

@jweiss
Copy link

jweiss commented Mar 4, 2013

Thank you for the pull request. I'm not sure we will implement it like this as it gives everybody access to the socket.
I would rather explicitly give it only to Nginx.
We will push a fix soon.

@joeyAghion
Copy link
Author

Thanks! I'll go ahead and close this.

@joeyAghion joeyAghion closed this Mar 5, 2013
@ziggythehamster
Copy link
Contributor

Any ETA on a fix on this? (Just realized via the forum post that adding "group": "nginx" to the stack JSON will fix the issue, though it's weird as hell to have to do that.)

@crekev
Copy link
Contributor

crekev commented Mar 21, 2013

a fix for this problem was published today with the new agent (version 106). You can check the installed agent version with sudo /usr/sbin/opsworks-agent-cli agent_report

@ziggythehamster
Copy link
Contributor

[kgable@yellowsubmarine ~]$ sudo /usr/sbin/opsworks-agent-cli agent_report

AWS OpsWorks Instace Agent State Report:

  Last activity was a "execute_recipes" on Thu Mar 21 13:10:42 UTC 2013
  Agent Status: The AWS OpsWorks agent is running as PID 1246
  Agent Version: 104, update needed

I'm assuming running an update dependencies command will update the agent. Trying that now :)

@jweiss
Copy link

jweiss commented Mar 21, 2013

Your agent will update itself automatically within 24h, update dependencies will not do it.

@ziggythehamster
Copy link
Contributor

I just stopped and restarted the instance, all is well (other than OpsWorks still showing a spinner next to "shutdown", but I figure it'll eventually decide to put an X there or something) :)

Thanks!

@tjhanley
Copy link

tjhanley commented Jul 4, 2013

I am still seeing this issue 😦

@awsrequena
Copy link
Contributor

I'll check this and get back to you

@awsrequena
Copy link
Contributor

I just tested it and could not reproduce it.

Did you app worked at some point? Can you post a gist with the chef log showing the failure?

@tjhanley
Copy link

tjhanley commented Jul 8, 2013

@awsrequena It worked the week before last, but only after following some of the information on the aws discussion group. I killed the original instances and had OpsWorks make new instances and since then they have these unicorn.sock permission issues.

With my fork of this repository: https://gist.github.com/tjhanley/9e9c83a235d2063ab107

Gist with the stock opsworks-cookbooks repository: https://gist.github.com/tjhanley/054f959d8b1d64599e41

@billinghamj
Copy link

I'm on version 206 and seem to be getting the same issue. Is there a way of forcing a rebuild of the instance?

@ziggythehamster
Copy link
Contributor

If you are instance store, stop and start the instance.

If you are not instance store, start a new instance in the same layer, boot it, and check if the problem is resolved. If so, terminate the old one from the OpsWorks console (stop -> delete).

I haven't had this problem in some time, and I ditched the "group": "nginx" part.

@billinghamj
Copy link

I actually only started using OpsWorks yesterday, so was quite surprised that I had the issue.

Also, I'm using Ubuntu 12.04, so I think the group has to be set to "www-data". I was finding that Unicorn was in the to "www-data" group whereas nginx was in the "nginx" group.

Killing the instances and remaking them seems to have sorted the problem, although I have no idea if the group has had any impact.

Thanks for the help.

@ziggythehamster
Copy link
Contributor

Nginx and Unicorn both need to be the same group, which is probably "nginx" in your case. Is is possible you picked Apache then switched to Nginx without a relaunch?

@billinghamj
Copy link

No, actually. I picked Unicorn/Nginx right from the start.

I believe this line is causing the difference for Ubuntu/Debian:

https://github.com/aws/opsworks-cookbooks/blob/master-chef-11.4/deploy/attributes/deploy.rb#L8

Probably just a convention thing - most Deb/Ubuntu stuff uses www-data.

seanslerner referenced this pull request in seanslerner/opsworks-cookbooks Mar 28, 2014
Note, the default value of the `mlockall` attribute is `false`
[elastic/elasticsearch#567].

However, in production environment, it is _highly_ recommended to
run with a `mlockall:true` setting -- thus the cookbook sets it to `true`.

If you encounter problems, try running with `mlockall:false`.

Closes #10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants