why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

tommaso159
hi,

i have a nginx server serving a ror app (1).

now i have added a second server section , different server_name
directive in nginx.conf serving up the same app but with a different
layout based on controlle rlogic based on the HOST_NAME.

it works locally, but the server still show HOSTNAME from server 1,
hence logic failing...


any ideas?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMfKjH6ZPOERwQjfd3ZGkbvnhj8o5eAOOTXjNnoiK1jSNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

Colin Law
On Wed, 7 Nov 2018 at 19:05, tom <[hidden email]> wrote:

>
> hi,
>
> i have a nginx server serving a ror app (1).
>
> now i have added a second server section , different server_name
> directive in nginx.conf serving up the same app but with a different
> layout based on controlle rlogic based on the HOST_NAME.
>
> it works locally, but the server still show HOSTNAME from server 1,
> hence logic failing...

I think you need to be a little more explicit on exactly what you mean
by HOSTNAME (or HOST_NAME, you don't seem sure which it is).

Colin

>
>
> any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMfKjH6ZPOERwQjfd3ZGkbvnhj8o5eAOOTXjNnoiK1jSNw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtwxkcXewu27Xfe2GaNKmdmRx4cXd%3DuTinQ2drFHMmy1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

Hassan Schroeder-2
In reply to this post by tommaso159
On Wed, Nov 7, 2018 at 11:05 AM tom <[hidden email]> wrote:

> it works locally, but the server still show HOSTNAME from server 1,
> hence logic failing...
>
> any ideas?

Sure: post your nginx config (or a sample version that demonstrates
the problem) along with something showing how you're determining
what requests the Rails app is receiving.

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBcunYsr3A%3Da0Qp0VEfXF%2Bb62mkh7Eq_74JzPRpPL%3DRNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

tommaso159
never mind.
did clear browser cache...too many windows... too much of a day...

i am trying to figure our why layout is not being triggerd in
applicaiton controller....

thx
again

On Wed, Nov 7, 2018 at 5:11 PM Hassan Schroeder
<[hidden email]> wrote:

>
> On Wed, Nov 7, 2018 at 11:05 AM tom <[hidden email]> wrote:
>
> > it works locally, but the server still show HOSTNAME from server 1,
> > hence logic failing...
> >
> > any ideas?
>
> Sure: post your nginx config (or a sample version that demonstrates
> the problem) along with something showing how you're determining
> what requests the Rails app is receiving.
>
> --
> Hassan Schroeder ------------------------ [hidden email]
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBcunYsr3A%3Da0Qp0VEfXF%2Bb62mkh7Eq_74JzPRpPL%3DRNg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdx6-8We6TN5F9GfrjFX4G0y2vAyC4YpROokqtij26CcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

Rob Jonson
somewhat off the topic - but just want to repeat my delight that HatchBox now handle all this server pain for me!

it's kinda like heroku - but they'll configure the server on your choice of host. I use DigitalOcean

I give them a fairly modest amount of money, and they make all this kind of thing very easy.
Adding an extra domain to the app is about three clicks. (app, configuration, type your new domain name, click add) They worry about the ngnix config and all that

I actually have an app like yours which behaves differently according to host. I just have this method in my application controller

def get_host
host = params[:host] || request.host

@host = HostInfo.with(host:host)
end

I use the params[:host] option to simplify local testing. It allows me to test localhost:3000/?host=domain.com

If you do want to check out hatchbox - this link gives me a referral bonus
https://hatchbox.io?via=rob


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3b2f8592-f3c6-4c67-abf8-be2c1f0ef2ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: why is HTTP_HOST set to "wrong" value on 2nd nginx server ?

tommaso159
thank you for the hint.

my problem is that the slection of th elayout works just fine in
development mode + dns in windows host file ; but no on production
server, it on,y says template not found...

thx
On Fri, Nov 9, 2018 at 6:56 AM Rob Jonson <[hidden email]> wrote:

>
> somewhat off the topic - but just want to repeat my delight that HatchBox now handle all this server pain for me!
>
> it's kinda like heroku - but they'll configure the server on your choice of host. I use DigitalOcean
>
> I give them a fairly modest amount of money, and they make all this kind of thing very easy.
> Adding an extra domain to the app is about three clicks. (app, configuration, type your new domain name, click add) They worry about the ngnix config and all that
>
> I actually have an app like yours which behaves differently according to host. I just have this method in my application controller
>
> def get_host
> host = params[:host] || request.host
>
> @host = HostInfo.with(host:host)
> end
>
> I use the params[:host] option to simplify local testing. It allows me to test localhost:3000/?host=domain.com
>
> If you do want to check out hatchbox - this link gives me a referral bonus
> https://hatchbox.io?via=rob
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3b2f8592-f3c6-4c67-abf8-be2c1f0ef2ad%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMesf7ng%3DF%3Dm_CxAazZewTEGQv1xpPPzdT5AFQCP3ch%3D3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.