Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

up vote 0 down vote accepted

It turns out this is not possible with nginx.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.