Beginner questions about proxy configuration and white space

Hello,

I have installed nginx on my personal computer and would like to use it
as a proxy to force authentication via modified http headers in various
browsers. There’s an add-on in firefox to do this, but none for Chrome,
which is why I am using nginx. I’ve edited configuration file to include
something like this under the http section:

server {
listen some_port;

location http://some_ip {
add_header X-h1 h1;
add_header X-h2 h2 h2;
add_header X-h3 h3;
add_header X-h4 h4;
add_header X-h5 h5;
add_header X-h6 h6 h6;
add_header X-h7 h7;
}
}

I figured that out from reading many examples and the wiki. Now, I do
not know how exactly to configure nginx to act as a proxy. I’ve read
through part of the wiki on the HttpProxy module, but I don’t have much
experience with web servers or proxies. Could someone point me in the
right direction?

Also, when editing the configuration file using the http headers module
(this: Module ngx_http_headers_module), can values have spaces
in them? Or should I put quotations around the whole thing? I read here:
How to Configure NGINX | Linode Docs that
whitespace doesn’t matter, but I just thought to double check, since I
saw no examples where values had spaces in them.

Thanks.

Posted at Nginx Forum:

proxy:

server {
listen some_ip:some_port default;

location / {
add_header X-h1 h1;
add_header X-h2 “h2 h2”;
add_header X-h3 h3;
add_header X-h4 h4;
add_header X-h5 h5;
add_header X-h6 “h6 h6”;
add_header X-h7 h7;
proxy_pass http://backend;
}
}

space: add a double quotes
add_header X-h2 “h2 h2”;

MagicBear

Posted at Nginx Forum:

I’ll try that out.

Thank you!

Posted at Nginx Forum:

if you are running nginx, you may use “nginx -s reload” to reload the
config.
or killall -9 nginx; nginx to restart nginx

2011/9/10 ynasser [email protected]

I don’t think it’s a problem with reloading the configuration file,
because I have been reloading it every time after I update and save it.

What is happening is that when I run ‘sudo nginx’, it doesn’t start and
outputs this error:

nginx: [emerg] bind() to some_ip:some_port failed (49: Can’t assign
requested address)

I can access some_ip:some_port just fine from a browser and ssh-ing into
it is not a problem.

Posted at Nginx Forum:

If you only using one ip, you can use listen 80 default;
The some_ip:some_port is using on my product server, it shows no
problem.

2011/9/10 ynasser [email protected]

It works now. My configuration looks like this:

server {
listen 80 default;

location / {
  proxy_pass http://some_ip:some_port;

  proxy_set_header X-h1 h1;
  proxy_set_header X-h2 h2;
  proxy_set_header X-h3 "h3 h3";
  }
}

I hope this help anyone else with this problem.

Posted at Nginx Forum:

I reinstalled nginx and re-added that directive to the new configutation
file. Now this happens:

sudo nginx
nginx: [emerg] bind() to 10.0.1.187:2525 failed (49: Can’t assign
requested address)

In regards to the example given above:

server {
listen some_ip:some_port default;

location / {
add_header X-h1 h1;
add_header X-h2 “h2 h2”;
add_header X-h3 h3;
add_header X-h4 h4;
add_header X-h5 h5;
add_header X-h6 “h6 h6”;
add_header X-h7 h7;
proxy_pass http://backend;
}
}

some_ip:some_port is the site that I’m trying to pass the headers to.
For http://backend, I’m using “http://127.0.0.1

Any help would be appreciated.

Posted at Nginx Forum: