WebFaction
Community site: login faq

I need to add a custom header to each response sent by nginx for my static-only application. With Apache I'd put the following in a .htaccess file:

Header set Access-Control-Allow-Origin "*"

How do I do it with nginx?

asked 11 Jan '11, 04:56

samlue
1613
accept rate: 0%


Custom headers are not supported by our nginx-based applications. You'll need to use an Apache-based application in order to do this.

permanent link

answered 11 Jan '11, 05:03

David L ♦♦
1.4k13
accept rate: 45%

I see. Is it possible, then, to create a Static/CGI/PHP app and, as its root dir, use a symlink to a dir in another application? After creating the Static/CGI/PHP application, I can't delete its directory in the shell, so replacing it with a symlink seems not possible?

(11 Jan '11, 05:10) samlue

Indeed it is.

We have specific applications dedicated to doing this: "Symbolic link to static-only" and "Symbolic link to Static/CGI/PHP".

In the "extra_info" field, just place the full path to the directory you'd like to use as the symlink source. The target will be the application name you choose.

(11 Jan '11, 05:17) David L ♦♦

Thank you, I overlooked that.

(11 Jan '11, 06:22) samlue

Surely you can add those specific headers, but you may end up having missing parts on a RESTful API that uses 20X status codes.

You can try to install a custom version of nginx on your application with HttpHeadersMoreModule.

In my way to use CORS on the deploy environment I pointed my API application (Rails in this case) as a subdirectory of a static application (http://my-static-app.com/api) and it worked nice. No cross-site requests there :)

permanent link

answered 24 Jul '12, 15:07

Juan Hoyos
11
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×29

question asked: 11 Jan '11, 04:56

question was seen: 6,222 times

last updated: 24 Jul '12, 15:07

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM