How to add subdomain in nginx server?

Follow these following steps to add a subdomain within Nginx server.

1. In the domain panel, add an A-record to point the new subdomain to your server

2. Register the new subdomain with Nginx server

sudo nano /etc/nginx/sites-available/

3. Use this simple configuration for the newly created file

server {
        listen 80;

        root /var/www/html/apps/youtube;
        index index.html index.htm index.nginx-debian.html;


        location / {
                try_files $uri $uri/ /index.html?$args;

4. To enable the configuration, make a symlink to the enabled sites

ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

5. The last thing to do is restart Nginx:

service nginx restart

6. If we activate SSL for our domain and receive the error ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY on Chrome. Then edit the ssl.conf with following settings

sudo nano /var/www/

And add following lines


Which is recommended by Cloudflare.

Leave a comment

Your email address will not be published. Required fields are marked *