login community 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 Jan 11 '11 at 04:56

samlue's gravatar image

samlue
62


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

answered Jan 11 '11 at 05:03

David%20L's gravatar image

David L ♦♦
132113

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?

(Jan 11 '11 at 05:10) samlue samlue's gravatar image

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.

(Jan 11 '11 at 05:17) David L ♦♦ David%20L's gravatar image

Thank you, I overlooked that.

(Jan 11 '11 at 06:22) samlue samlue's gravatar image

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 :)

answered Jul 24 '12 at 15:07

Juan%20Hoyos's gravatar image

Juan Hoyos
11

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
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

Tags:

×127
×19

Asked: Jan 11 '11 at 04:56

Seen: 1,545 times

Last updated: Jul 24 '12 at 15:07

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited