Nginx配置HTTP跳转HTTPS

server {
	listen	443 ssl;
	listen	80;
	server_name	www.demo2023.com;

	......

	# 497、301状态码,重定向到HTTPS
	error_page	497 301 https://$http_host$request_uri;

	location / {
		# 允许跨域
		if ($http_origin ~* (https?://.*.demo2023.com$)) {
			add_header	Access-Control-Allow-Origin $http_origin always;
			add_header	Access-Control-Allow-Credentials true;
			add_header	Access-Control-Allow-Methods 'GET,POST';
		}

		......

	}
}