0

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?

-1

It turns out this is not possible with nginx.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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