Nginx multiple modified configs

Is it possible to sort websites into their respective configs instead of having it all in the local.conf file? I have a php website that I run on one of my domains, and the MIAB updates always overwrite my php additions without which my CMS doesn’t work. What should I do to make my life easier?

Thanks.

You can overwrite a sites nginx config by putting a new one in /home/user-data/www/domain.conf

If the file does not exist, create it, add what you want (like overwriting document root, etc) and save, restart nginx (service nginx restart) and it should take affect. If it does not take affect you will need to run web update in the mailinabox git directory under your own user account.

An example of this is the old way of enabling PHP on sites ( Enable PHP on sites ) as you can see here.

1 Like

I thought of doing that, but nginx throws this error:
nginx: [emerg] “server” directive is not allowed here.

and there was also a ‘duplicate’ error.

I don’t know what can be included, but I would check nginx’s documentation for further details on how it loads external configs. (This is as far as my knowledge goes, sorry)

Edit : You will NOT be able to overwrite the server directive, only what would be inside the server directive.

Thanks for your help, anyway!

1 Like

You will NOT be able to overwrite the server directive, only what would be inside the server directive.

1 Like

Ah, I see. So just to be clear, I name the .conf inside the /home/user-data/www/ directory as the website, and just throw the needed lines to enable php support? Without any server {} surrounding them?

Yes I believe so (since the file will only modify domain.com’s config, not domain2.com)

After modifying the new file you make sure you run web-update script under /home/your_username/mailinabox/tools

Also keep in mind, you can still host websites outside of mailinabox.

Not sure how that would work with miab controlling my whole vps. I’ll just leave it be )

Set the A record in “custom DNS” for a domain you want externally hosted to the IP of the external web host. :slight_smile:

Done that already :wink: I’ve many sites and for those less important ones I found miab can serve quite well. Been changing my nginx conf by hand for years, a bit late in finding out this neat trick, will save tons of time!

1 Like