Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up nginx + uwsgi. I plan to have multiple apps with different settings running on separate subdomains (e.g. sub1.example.com, sub2.example.com).

One of the nice things about uwsgi, is configuration rewriting. For example, I can create a skeleton for all uwsgi apps and use %n to represent the current filename (without extension).

$ cat > uwsgi.skel
[uwsgi]
...
socket = /var/run/uwsgi/%n.sock
...

Now I can just create new uwsgi instances using ln -s.

$ ln -s /etc/uwsgi/conf/sub1.example.com.ini /etc/uwsgi/conf/uwsgi.skel
$ ln -s /etc/uwsgi/conf/sub2.example.com.ini /etc/uwsgi/conf/uwsgi.skel

The nginx configuration for the servers will be exactly the same EXCEPT for the domain name. I'd like to do something like this:

cat > /etc/nginx/sites-available/app.skel
server {
    listen 80;
    server_name $file_name;
    location / { try_files $uri @app }
    location @app {
        include uwsgi_params;
        uwsgi_pass unix://var/run/uwsgi/$file_name.sock 
    }
}
$ ln -s /etc/nginx/sites-enabled/sub1.example.com /etc/nginx/sites-available/app.skel
$ ln -s /etc/nginx/sites-enabled/sub2.example.com /etc/nginx/sites-available/app.skel

Is there any way to do replacement in nginx similar to what is available with uwsgi? What is the best way to achieve configuration sharing between nginx applications?

share|improve this question
    
This answers your question: stackoverflow.com/questions/33794549/… Use ${host}. Done. – David Betz Feb 16 at 0:46
up vote -1 down vote accepted

It turns out this is not possible with nginx.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .