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';
		}

		......

	}
}


本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码

)">
< <上一篇
下一篇>>