nginx reverse proxy with two nexus urls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

nginx reverse proxy with two nexus urls

Igor Fedorenko-3
Does anyone have a working example that shows how to expose nexus over
both :80/ and :8081/nexus urls behind nginx reverse proxy?

The nexus book explains how to do this for httpd [1], but porting
suggested configuration to nginx is well beyond what I know about nginx
and http in general. No matter what I do, all links served over
:8081/nexus url point at :8081/, i.e. without 'nexus' prefix.

Thank you in advance.

[1] http://books.sonatype.com/nexus-book/reference/install-sect-proxy.html

--
Regards,
Igor

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nginx reverse proxy with two nexus urls

Rich Seddon
You'll need something like this for port 80 running on /nexus:

  location /nexus {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_pass http://localhost:8081/nexus;
            proxy_redirect     default;
      }

You'll also most likely want to set "proxy_buffering  off;", if you don't turn this off you're going to run into trouble because nginx will buffer large uploads to temporary files.

I'm not sure I understand what you're trying to do with port 8081 though.  Is that the port nexus is running on?  If so, why do you need to go through the reverse proxy.  Just be sure not to check "force base url" in the Nexus base URL under "administration/server" and you'll be able to access Nexus directly, as well as through the reverse proxy.

Rich



On Sat, Oct 11, 2014 at 10:41 PM, Igor Fedorenko <[hidden email]> wrote:
Does anyone have a working example that shows how to expose nexus over
both :80/ and :8081/nexus urls behind nginx reverse proxy?

The nexus book explains how to do this for httpd [1], but porting
suggested configuration to nginx is well beyond what I know about nginx
and http in general. No matter what I do, all links served over
:8081/nexus url point at :8081/, i.e. without 'nexus' prefix.

Thank you in advance.

[1] http://books.sonatype.com/nexus-book/reference/install-sect-proxy.html

--
Regards,
Igor

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nginx reverse proxy with two nexus urls

Igor Fedorenko-3
I want to expose nexus as http://foo/ on port 80 and as
http://foo:8081/nexus on port 8081. The book chapter suggested
it was possible with httpd (unless I misunderstood), but I could not
make it work with nginx.

I ended up doing redirect from http://foo:8081/nexus to http://foo/. It
adds an extra round-trip, but I want clients to migrate to the new url
anyways, so it's acceptable.

Thank you for "proxy_buffering off;" tip, I was not aware of this.

Do you have any other advice for running nexus behind nginx reverse proxy?

--
Regards,
Igor



On 2014-10-13, 10:43, Rich Seddon wrote:

> You'll need something like this for port 80 running on /nexus:
>
>    location /nexus {
>        proxy_set_header Host $host;
>        proxy_set_header X-Real-IP $remote_addr;
>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>
>        proxy_pass http://localhost:8081/nexus;
>              proxy_redirect     default;
>        }
>
> You'll also most likely want to set "proxy_buffering  off;", if you
> don't turn this off you're going to run into trouble because nginx will
> buffer large uploads to temporary files.
>
> I'm not sure I understand what you're trying to do with port 8081
> though.  Is that the port nexus is running on?  If so, why do you need
> to go through the reverse proxy.  Just be sure not to check "force base
> url" in the Nexus base URL under "administration/server" and you'll be
> able to access Nexus directly, as well as through the reverse proxy.
>
> Rich
>
>
>
> On Sat, Oct 11, 2014 at 10:41 PM, Igor Fedorenko <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Does anyone have a working example that shows how to expose nexus over
>     both :80/ and :8081/nexus urls behind nginx reverse proxy?
>
>     The nexus book explains how to do this for httpd [1], but porting
>     suggested configuration to nginx is well beyond what I know about nginx
>     and http in general. No matter what I do, all links served over
>     :8081/nexus url point at :8081/, i.e. without 'nexus' prefix.
>
>     Thank you in advance.
>
>     [1]
>     http://books.sonatype.com/__nexus-book/reference/install-__sect-proxy.html
>     <http://books.sonatype.com/nexus-book/reference/install-sect-proxy.html>
>
>     --
>     Regards,
>     Igor
>
>     ------------------------------__------------------------------__---------
>     To unsubscribe, e-mail: [hidden email]
>     <mailto:[hidden email]>
>     For additional commands, e-mail: [hidden email]
>     <mailto:[hidden email]>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nginx reverse proxy with two nexus urls

Rich Seddon
Enable sendfile, this allows nginx to copy from one file descriptor to another within the kernel, this is a lot more efficient: sendfile on;

Also if you set up SSL on nginx you'll need to add "proxy_set_header X-Forwarded-Proto https;" to your setup.


Rich


On Mon, Oct 13, 2014 at 10:25 AM, Igor Fedorenko <[hidden email]> wrote:
I want to expose nexus as http://foo/ on port 80 and as
http://foo:8081/nexus on port 8081. The book chapter suggested
it was possible with httpd (unless I misunderstood), but I could not
make it work with nginx.

I ended up doing redirect from http://foo:8081/nexus to http://foo/. It
adds an extra round-trip, but I want clients to migrate to the new url
anyways, so it's acceptable.

Thank you for "proxy_buffering off;" tip, I was not aware of this.

Do you have any other advice for running nexus behind nginx reverse proxy?

--
Regards,
Igor



On 2014-10-13, 10:43, Rich Seddon wrote:
You'll need something like this for port 80 running on /nexus:

   location /nexus {
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

       proxy_pass http://localhost:8081/nexus;
             proxy_redirect     default;
       }

You'll also most likely want to set "proxy_buffering  off;", if you
don't turn this off you're going to run into trouble because nginx will
buffer large uploads to temporary files.

I'm not sure I understand what you're trying to do with port 8081
though.  Is that the port nexus is running on?  If so, why do you need
to go through the reverse proxy.  Just be sure not to check "force base
url" in the Nexus base URL under "administration/server" and you'll be
able to access Nexus directly, as well as through the reverse proxy.

Rich



On Sat, Oct 11, 2014 at 10:41 PM, Igor Fedorenko <[hidden email]
<mailto:[hidden email]>> wrote:

    Does anyone have a working example that shows how to expose nexus over
    both :80/ and :8081/nexus urls behind nginx reverse proxy?

    The nexus book explains how to do this for httpd [1], but porting
    suggested configuration to nginx is well beyond what I know about nginx
    and http in general. No matter what I do, all links served over
    :8081/nexus url point at :8081/, i.e. without 'nexus' prefix.

    Thank you in advance.

    [1]
    http://books.sonatype.com/__nexus-book/reference/install-__sect-proxy.html
    <http://books.sonatype.com/nexus-book/reference/install-sect-proxy.html>

    --
    Regards,
    Igor

    ------------------------------__------------------------------__---------
    To unsubscribe, e-mail: nexus-user-unsubscribe@__sonatype.org
    <mailto:[hidden email]>
    For additional commands, e-mail: [hidden email]
    <mailto:[hidden email]>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nginx reverse proxy with two nexus urls

Igor Fedorenko-3
In reply to this post by Igor Fedorenko-3
Looks like I spoke too soon. Not all maven plugins honour http 302
redirects it seems, so I still need to figure out how to expose the
same nexus instance both as http://foo/ and http://foo:8081/nexus
through nginx. Any working examples anyone can share? Is this even possible?

--
Regards,
Igor

On 2014-10-13, 11:25, Igor Fedorenko wrote:

> I want to expose nexus as http://foo/ on port 80 and as
> http://foo:8081/nexus on port 8081. The book chapter suggested
> it was possible with httpd (unless I misunderstood), but I could not
> make it work with nginx.
>
> I ended up doing redirect from http://foo:8081/nexus to http://foo/. It
> adds an extra round-trip, but I want clients to migrate to the new url
> anyways, so it's acceptable.
>
> Thank you for "proxy_buffering off;" tip, I was not aware of this.
>
> Do you have any other advice for running nexus behind nginx reverse proxy?
>
> --
> Regards,
> Igor
>
>
>
> On 2014-10-13, 10:43, Rich Seddon wrote:
>> You'll need something like this for port 80 running on /nexus:
>>
>>    location /nexus {
>>        proxy_set_header Host $host;
>>        proxy_set_header X-Real-IP $remote_addr;
>>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>
>>        proxy_pass http://localhost:8081/nexus;
>>              proxy_redirect     default;
>>        }
>>
>> You'll also most likely want to set "proxy_buffering  off;", if you
>> don't turn this off you're going to run into trouble because nginx will
>> buffer large uploads to temporary files.
>>
>> I'm not sure I understand what you're trying to do with port 8081
>> though.  Is that the port nexus is running on?  If so, why do you need
>> to go through the reverse proxy.  Just be sure not to check "force base
>> url" in the Nexus base URL under "administration/server" and you'll be
>> able to access Nexus directly, as well as through the reverse proxy.
>>
>> Rich
>>
>>
>>
>> On Sat, Oct 11, 2014 at 10:41 PM, Igor Fedorenko <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Does anyone have a working example that shows how to expose nexus
>> over
>>     both :80/ and :8081/nexus urls behind nginx reverse proxy?
>>
>>     The nexus book explains how to do this for httpd [1], but porting
>>     suggested configuration to nginx is well beyond what I know about
>> nginx
>>     and http in general. No matter what I do, all links served over
>>     :8081/nexus url point at :8081/, i.e. without 'nexus' prefix.
>>
>>     Thank you in advance.
>>
>>     [1]
>>
>> http://books.sonatype.com/__nexus-book/reference/install-__sect-proxy.html
>>
>>
>> <http://books.sonatype.com/nexus-book/reference/install-sect-proxy.html>
>>
>>     --
>>     Regards,
>>     Igor
>>
>>
>> ------------------------------__------------------------------__---------
>>     To unsubscribe, e-mail: [hidden email]
>>     <mailto:[hidden email]>
>>     For additional commands, e-mail: [hidden email]
>>     <mailto:[hidden email]>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...