Skip to content

Instantly share code, notes, and snippets.

@deadenddeveloper
Last active October 21, 2021 18:49
Show Gist options
  • Save deadenddeveloper/47375978e9ae54c9d6cac9f49a4065c4 to your computer and use it in GitHub Desktop.
Save deadenddeveloper/47375978e9ae54c9d6cac9f49a4065c4 to your computer and use it in GitHub Desktop.
Subdomain configuration

NGINX

server {
	root /var/www/html/sub.example.com/;
	index index.php index.html index.htm index.nginx-debian.html;

	listen 80;
	listen [::]:80;

	server_name sub.example.com;

	location / {
		try_files $uri $uri/ /index.php?$query_string;
	}

	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php7.0-fpm.sock;
	}

	# it should appear after certbot

	listen [::]:443 ssl; # managed by Certbot
	listen 443 ssl; # managed by Certbot
	ssl_certificate /etc/letsencrypt/live/sub.example.com/fullchain.pem; # managed by Certbot
	ssl_certificate_key /etc/letsencrypt/live/sub.example.com/privkey.pem; # managed by Certbot
	include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Certificate

certbot certonly -d sub.example.com

DNS

It is important to add A record with a subdomain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment