# 'Primary' domain in server block?

**URL:** <https://www.ruby-forum.com/t/primary-domain-in-server-block/227201>\
**Category:** NGINX\
**Created:** [March 7, 2013, 10:30am UTC](https://www.ruby-forum.com/t/primary-domain-in-server-block/227201 "2013-03-07T10:30:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b3f665/32.png) [@Tom\_Barrett](https://www.ruby-forum.com/u/Tom_Barrett)\
**Post date:** [March 7, 2013, 10:30am UTC](https://www.ruby-forum.com/t/primary-domain-in-server-block/227201/1 "2013-03-07T10:30:25Z")

</div>

Hi

I’m doing some work with PayPal integration. My server block looks like  
this:

server {  
server\_name [dev01.localmap.net](http://dev01.localmap.net) [dev01.devsite.co.uk](http://dev01.devsite.co.uk);  
…  
}

The work is being done in under ‘[dev01.devsite.co.uk](http://dev01.devsite.co.uk)’ domain. However,  
for  
link backs from PayPal, it is working out that it should be ’  
[dev01.localmap.net](http://dev01.localmap.net)’. If I switch the two around in the server block,  
then  
PayPal picks that up.

How is PayPal doing that? And are there any config settings I can use to  
change this behaviour?

It is not a major issue, mainly it is confusing some testers who are  
‘losing’ cookie data. I’m looking to explain the situation and make sure  
we  
have a nice solution to it.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![Tom\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b3f665/32.png) [@Tom\_Barrett](https://www.ruby-forum.com/u/Tom_Barrett)\
**Post date:** [March 7, 2013, 6:07pm UTC](https://www.ruby-forum.com/t/primary-domain-in-server-block/227201/2 "2013-03-07T18:07:22Z")

</div>

On Thu, Mar 07, 2013 at 09:30:01AM +0000, Tom Barrett wrote:

Hi there,

> I’m doing some work with PayPal integration.

How does nginx talk to your PayPal integration system?

proxy\_pass, fastcgi\_pass, something else?

> The work is being done in under ‘[dev01.devsite.co.uk](http://dev01.devsite.co.uk)’ domain. However, for  
> link backs from PayPal, it is working out that it should be ’  
> [dev01.localmap.net](http://dev01.localmap.net)’. If I switch the two around in the server block, then  
> PayPal picks that up.

In nginx, the variable $server\_name is the first entry for the  
server\_name  
directive in the appropriate server{} block.

There are circumstances in which the variable $host will take that  
value.

> How is PayPal doing that?

Presumably you’re giving the information it to PayPal somehow?

> And are there any config settings I can use to  
> change this behaviour?

Probably. What’s your current relevant config?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Tom\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b3f665/32.png) [@Tom\_Barrett](https://www.ruby-forum.com/u/Tom_Barrett)\
**Post date:** [March 8, 2013, 9:43pm UTC](https://www.ruby-forum.com/t/primary-domain-in-server-block/227201/3 "2013-03-08T21:43:29Z")

</div>

On Fri, Mar 08, 2013 at 08:53:34AM +0000, Tom Barrett wrote:

> On 7 March 2013 17:06, Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > On Thu, Mar 07, 2013 at 09:30:01AM +0000, Tom Barrett wrote:

Hi there,

> I think perhaps my use of the word ‘integration’ was a little  
> grandiose. The general server setup is PHP fastcgi with a WordPress  
> installation.

So: fastcgi is involved.

nginx interacts with the fastcgi server by sending key/value pairs from  
fastcgi\_param directives. That is (pretty much) all it does.

The fastcgi server will (typically) use some specific fastcgi\_param  
keys for itself, and then make all of the key/values available to the  
php script.

What happens after that is nothing to do with nginx.

> > > How is PayPal doing that?
> > 
> > Presumably you’re giving the information it to PayPal somehow?
> 
> So, however PayPal is grabbing it’s information, it gets the first entry in  
> the server\_name directive. And that’s my only option?

No. It sounds like your php script is talking to PayPal, and so your php  
script is sending the information. If you know what information you want  
to send, either change your php script to send only that; or else read  
your php script to see what key names it uses, and change your nginx to  
send the values you want for those keys.

> Well, assuming my above statement is correct, then only the server\_name  
> directive is relevant?

That depends on what your php script does.

> It is a pretty trivial setup: [http://pastebin.com/SdaB1ZW4](http://pastebin.com/SdaB1ZW4)

My guess is that your php script uses the value of SERVER\_NAME when it  
talks to PayPal. Your config sets SERVER\_NAME to whatever $server\_name  
is  
(in the fastcgi\_param directives, in the “include” file).

If my guess is correct, then if you send SERVER\_NAME with the value of  
“[www.example.com](http://www.example.com)”, then that’s what PayPal will see, and will use.

You have the php script; you don’t need to guess.

You can set a fixed string, or you can use another variable – perhaps  
$host is closer to what you want it to be. Or maybe PayPal will use some  
other key if SERVER\_NAME is not set to anything. It shouldn’t be too  
difficult to set up a test system to learn some of what PayPal is doing.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Tom\_Barrett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b3f665/32.png) [@Tom\_Barrett](https://www.ruby-forum.com/u/Tom_Barrett)\
**Post date:** [March 8, 2013, 9:54am UTC](https://www.ruby-forum.com/t/primary-domain-in-server-block/227201/4 "2013-03-08T09:54:09Z")

</div>

On 7 March 2013 17:06, Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Thu, Mar 07, 2013 at 09:30:01AM +0000, Tom Barrett wrote:
> 
> Hi there,

Thanks for reading 🙂

> I’m doing some work with PayPal integration.
> 
> How does nginx talk to your PayPal integration system?

I think perhaps my use of the word ‘integration’ was a little  
grandiose. The general server setup is PHP fastcgi with a WordPress  
installation.  
The link to the PayPal account is via a simple HTML form with a price  
and  
submit button.

In nginx, the variable $server\_name is the first entry for the  
server\_name

> directive in the appropriate server{} block.
> 
> There are circumstances in which the variable $host will take that value.
> 
> > How is PayPal doing that?
> 
> Presumably you’re giving the information it to PayPal somehow?

So, however PayPal is grabbing it’s information, it gets the first entry  
in  
the server\_name directive. And that’s my only option?

> > And are there any config settings I can use to  
> > change this behaviour?
> 
> Probably. What’s your current relevant config?

Well, assuming my above statement is correct, then only the server\_name  
directive is relevant?

It is a pretty trivial setup: [http://pastebin.com/SdaB1ZW4](http://pastebin.com/SdaB1ZW4)
