I currently serve a web app on a Ubuntu server. Here's the configuration I
use:

In "/etc/nginx/sites-available/<app-name>":

server {
    listen 80;

    location / {
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header  Host             $http_host;
        proxy_redirect    off;
        proxy_pass        http://127.0.0.1:4000;
    }
}


Then I enable this configuration by adding a symbolic link:

cd /etc/nginx/sites-enabled
ln -s <app-name> ../sites-available/<app-name>


Then I create an upstart job to run the server in
"/etc/init/<app-name>.conf:

description "<description of server>"
author "<your name>"

start on startup
stop on shutdown

setuid deploy
chdir /deploy
console log

env PORT=4000
exec java -jar <name of uberjar file>.jar


The jar file I place in "/deploy", a directory I've added in at the top
level.

If all goes according to plan, then I can reload nginx and start my server:

reload nginx

start <app-name>


Hope that helps.

- James



On 25 December 2013 11:42, Zeynel <azeyn...@gmail.com> wrote:

> Ok, I worked through the tutorial referenced
> http://clojure-doc.org/articles/tutorials/basic_web_development.html#build-and-run-itand
>  I created a jar file and ran it with $ java -jar -my-webapp.jar. This
> works. But my understanding is that this is would not work for production.
> I need to use nginx as proxy to jetty (or immutant?). I am trying to figure
> out the correct configuration for jetty and nginx. Each tutorial appears to
> be different and so far I couldn't make it work.
>
>
> On Friday, December 20, 2013 9:39:07 AM UTC-4, David Della Costa wrote:
>
>> Hi Zeynel,
>>
>> I don't know if setting things up the way I've laid out there is such a
>> great idea.  What I would do instead is set the port and whatnot in the
>> jetty configuration inside of ring, assuming that's what you're using
>> (this assumes a lot about how your app is set up, so let me know if this
>> doesn't match your setup):
>>
>> http://ring-clojure.github.io/ring/ring.adapter.jetty.html
>>
>> Then, I would compile an uberjar with lein, like so:
>>
>> $ lein uberjar
>>
>> In your startup script, as Curtis laid out, call the jar file using
>> something like:
>>
>> /path/to/java -jar /path/to/uberjar
>>
>> That will be much simpler than what I have in my tutorial...which I
>> should really update, now that you mention it!
>>
>> DD
>>
>> (2013/12/19 9:28), Zeynel wrote:
>> > I am following your tutorial, but I am stuck with Jetty configuration.
>> > My installation does not seem to have a /contexts directory. Where is
>> it?
>> >
>> > On Tuesday, December 17, 2013 9:02:19 AM UTC-4, David Della Costa
>> wrote:
>> >
>> >     I have not done this specifically with Nginx but I suspect you
>> probably
>> >     want something like what I set up with Apache + Jetty:
>> >
>> >     https://github.com/ddellacosta/Clojure-under-
>> Jetty-and-Apache#setting-up-jetty-with-apache-httpd
>> >     <https://github.com/ddellacosta/Clojure-under-
>> Jetty-and-Apache#setting-up-jetty-with-apache-httpd>
>> >
>> >
>> >     That is, set up Nginx to act as a proxy for Jetty:
>> >
>> >     http://nginx.org/en/docs/beginners_guide.html#proxy
>> >     <http://nginx.org/en/docs/beginners_guide.html#proxy>
>> >
>> >     One difference with how I would do it these days (vs. what I wrote
>> in
>> >     the piece above) is that I would probably simply push out an
>> uberjar
>> >     with lein which I would run with Java via an init script--for
>> example,
>> >     if using Ubuntu:
>> >
>> >     http://upstart.ubuntu.com/cookbook/#run-a-java-application
>> >     <http://upstart.ubuntu.com/cookbook/#run-a-java-application>
>> >
>> >     So, I would imagine the basic construction would be something like:
>> >     ring
>> >     app w/jetty or http-kit, packaged as an uberjar (lein uberjar),
>> then
>> >     set
>> >     up to run via an init script (via upstart in your case) on an
>> >     alternative port, which is proxied by Nginx as in the link above.
>> >
>> >     Hope this helps--
>> >
>> >     DD
>> >
>> >     (2013/12/17 21:44), Zeynel wrote:
>> >     > I've set up a home server with ubuntu and nginx and I can serve
>> >     static
>> >     > pages. Now I want to add clojure but I am not sure what I need to
>> >     do. I
>> >     > asked the same question in StackOverflow but for some reason it
>> is
>> >     voted
>> >     > to be
>> >     > closed:
>> >     http://stackoverflow.com/questions/20632987/how-to-
>> serve-clojure-pages-with-nginx
>> >     <http://stackoverflow.com/questions/20632987/how-to-
>> serve-clojure-pages-with-nginx>
>> >
>> >     >
>> >     > Can you please direct me to documentation where I can read about
>> >     this?
>> >     > Some issues that I don't understand are: how do I tell nginx that
>> >     I am
>> >     > using clojure? Where do I install clojure, in the server? Where
>> do I
>> >     > create the clojure files? Thanks.
>> >     >
>> >     > --
>> >     > --
>> >     > You received this message because you are subscribed to the
>> Google
>> >     > Groups "Clojure" group.
>> >     > To post to this group, send email to clo...@googlegroups.com
>> >     <javascript:>
>> >     > Note that posts from new members are moderated - please be
>> patient
>> >     with
>> >     > your first post.
>> >     > To unsubscribe from this group, send email to
>> >     > clojure+u...@googlegroups.com <javascript:>
>> >     > For more options, visit this group at
>> >     > http://groups.google.com/group/clojure?hl=en
>> >     <http://groups.google.com/group/clojure?hl=en>
>> >     > ---
>> >     > You received this message because you are subscribed to the
>> Google
>> >     > Groups "Clojure" group.
>> >     > To unsubscribe from this group and stop receiving emails from it,
>> >     send
>> >     > an email to clojure+u...@googlegroups.com <javascript:>.
>> >     > For more options, visit https://groups.google.com/groups/opt_out
>> >     <https://groups.google.com/groups/opt_out>.
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@googlegroups.com
>> > Note that posts from new members are moderated - please be patient with
>> > your first post.
>> > To unsubscribe from this group, send email to
>> > clojure+u...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to clojure+u...@googlegroups.com.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to