Forum: NGINX Problem configuring Nginx to host SpreeCommerce - 502 error

Posted by Joseph O. (joseph_o)
on 2013-03-06 03:57
Attachment: nginx.conf (2,18 KB)
Attachment: mjtb-site (2,04 KB)
I have had a terribly difficult time deploying SpreeCommerce, despite
(or perhaps because of) following the Spree documentation. I have
eventually gotten to the point where the Capistrano deployment runs
through entirely, but I seem to have configured Nginx incorrectly, as I
am getting a "502 - Bad Gateway" error. My current nginx.conf and site
configuration files are attached; I have tried the recommendations from
several different sources but no combination of options seems to have
any effect.
Posted by mex (Guest)
on 2013-03-06 07:07
(Received via mailing list)
looks like a recursion to me, no?
you point your nginx.conf to proxy_pass
to http://www.masterjoestoybox.net/
and then you define with your mjtb
a config that listens to www.masterjoestoybox.net
and proxy_passes to http://www.masterjoestoybox.net/

and you configure a upstream unicorn_server in your
nginx.conf but never use it?

maybe you can throw away the mjtb - config

btw,
http://wiki.nginx.org/IfIsEvil
http://wiki.nginx.org/Pitfalls



regards,


mex

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236971,236973#msg-236973
Posted by Joseph O. (joseph_o)
on 2013-03-06 15:53
Ah, thank you. Removing the site configuration file did fix the gateway
error, but now the server is still pointing at the default Nginx welcome
page. Can you (or anyone else here) give me any advice on how to get the
server to point to my actual service?

BTW, you pointed out that there was an upstream Unicorn server
configured, something that I wasn't sure was necessary when I was
following the instructions; the Unicorn workers should in fact be on the
same host as the web server. I had thought that the way it was defined,
using a temporary socket, was correct for the layout I have, but it
sounds as if I misunderstood this (and probably a lot of other things).
Can you advise me on configuring the Unicorn workers correctly?

If there is any additional information or any other configuration files
which would help, please let me know.
Posted by mex (Guest)
on 2013-03-06 17:33
(Received via mailing list)
Joseph O. Wrote:
-------------------------------------------------------
> Ah, thank you. Removing the site configuration file did fix the
> gateway
> error, but now the server is still pointing at the default Nginx
> welcome
> page. Can you (or anyone else here) give me any advice on how to get
> the
> server to point to my actual service?

proxy_pass should do the trick

maybe you post your actual config.

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236971,237014#msg-237014
Posted by Joseph O. (joseph_o)
on 2013-03-06 17:55
Attachment: unicorn.rb (2,13 KB)
Attachment: deploy.rb (2,65 KB)
I'm not sure what you mean here; Which aspects of the actual
configuration? The Capistrano deployment, the Unicorn.rb file, or some
other part of the Nginx configuration? I've attached the former two,
with the sensitive data masked out of course, but I'm not certain what
else you would need.

I did correct the socket path (it is now set to /tmp/spree.sock in both
the deploy.rb and nginx.conf), but I am unclear about what to do with
the proxy_pass settings.
Posted by mex (Guest)
on 2013-03-06 21:05
(Received via mailing list)
your nginx-conf please that points to your upstream <and defines your
listening server {}  :)

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236971,237029#msg-237029
Posted by Joseph O. (joseph_o)
on 2013-03-06 23:14
*sigh* Clearly I am missing something here, as the only nginx.conf file 
I have is the one I posted last night. There is no upstream server; the 
code for that was from the example config file I was trying to modify 
for my purposes.

It seems that this copypasta approach isn't adequate for setting this up 
properly (I can't say I'm too surprised, but the Spree documentation I 
was going by implied that it would be), and that I will need to actually 
understand how Nginx works if I am to get anywhere with this. At this 
point, a tutorial or other documentation is probably what I need most. 
I had hoped that the problem was fairly simple, and could be fixed by 
some tweaking; it now is clear that the Spree documentation isn't work 
the electrons it is printed on.
Posted by mex (Guest)
on 2013-03-07 09:26
(Received via mailing list)
Joseph O. Wrote:
-------------------------------------------------------

ok, first make sure your railsapp is loading as expected and
working w/out nginx in front; you can check it from that machine using
w3m/lynx or telnet. if this works we'll check the nginx-part.


> *sigh* Clearly I am missing something here, as the only nginx.conf
> file
> I have is the one I posted last night. There is no upstream server;
> the
> code for that was from the example config file I was trying to modify
> for my purposes.

you define a upstream {} section but you dont use it later, instead of
proxy_pass $upstream you define proxy_pass to use a hostname
instead of your upstream; thats a mismatch in your config




>
> It seems that this copypasta approach isn't adequate for setting this
> up properly

+1 :)

you'll find some howtos and best-practice-guides for various 
applications
here: http://wiki.nginx.org/Configuration

but understanding what you're doing is key for long-time-happyness.
basically, your setup is quite simple and straight-forward.



regards,


mex

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236971,237037#msg-237037
Posted by Joseph O. (joseph_o)
on 2013-03-08 00:58
Attachment: nginx.conf (3,05 KB)
OK, so I've gone through the documentation on the Nginx wiki, and I 
still only have a minimal grasp on how to configure the it to serve 
Spree via Unicorn. Things are now back where they started (with a 502 
error), but I am making some progress, however, in that the server now 
points to the custom error pages I made, rather than the default ones. 
Oh well...

Attached is the current version of my nginx.conf file.
Posted by mex (Guest)
on 2013-03-09 10:15
(Received via mailing list)
ok,your config is a little confused.

in your @ruby - part you should proxy_pass to your unicorn - server
proxy_pass        http://unicorn_server;
(thats why you put your definition there :)




-------------------------------------------------------
> OK, so I've gone through the documentation on the Nginx wiki, and I
> still only have a minimal grasp on how to configure the it to serve
> Spree via Unicorn. Things are now back where they started (with a 502
> error), but I am making some progress, however, in that the server now
>
> points to the custom error pages I made, rather than the default ones.
>
> Oh well...
>
> Attached is the current version of my nginx.conf file.



> http://mailman.nginx.org/mailman/listinfo/nginx
Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,236971,237153#msg-237153
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.