域名不带 www 跳转到www

server {
	listen 80;
	server_name www.your-domain.com;
	rewrite ^(.*)$  https://www.your-domain.com$1 permanent;
}
server {
	listen 443 ssl;
	server_name www.your-domain.com;

	ssl_certificate /home/ssl_certificate/your-domain.com.pem;
	ssl_certificate_key /home/ssl_certificate/your-domain.com.key; 
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_session_timeout  5m;

	if ( $host != 'www.your-domain.com' ) {
		rewrite ^(.*)$ https://www.your-domain.com$1 permanent;
	}
	
	root /var/www/html;

	index index.html index.htm index.nginx-debian.html;

	# server_name _;

	location / {
		proxy_pass http://127.0.0.1:8080;
	}
}
此条目发表在nginx分类目录。将固定链接加入收藏夹。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注