Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bloomanity's avatar

Nginx Sites Order

Is there a way to test the order of the config files that are loaded when a request comes in?

I have the main domain and a subdomain with ssl, both with different sites, and work as expected. I also have another subdomain, with another site, that is not included in the SSL certificate and the browser tries to load https for it.

I'd like to test the flow for that request somehow and see where is the https applied, because the server blog for that subdomain only listens for :80

0 likes
3 replies
bashy's avatar

Nginx orders the configuration files based on ASCII. So 00-default (sometimes the default file) will be first. 10-example could be the next one.

If you haven't put the hostnames in the server_name, you will need to re-name the configs. Or put listen default_server;

More info http://nginx.org/en/docs/http/request_processing.html

Bloomanity's avatar

renaming the files applies to the symlinks from sites-enabled or the ones in sites-available?

bashy's avatar

I don't name mine for ordering because I don't have to. You should be explicitly setting the server_name so it matches. And you should have a catch-all vhost with

listen 80 default_server; // or 443 for ssl

Please or to participate in this conversation.