nginx配置访问不同文件夹下的网页

/ 后端 / 没有评论 / 312浏览

简单记录下

server {
	listen 80;
	server_name xxx;
	return 301 https://$server_name$request_uri;
	access_log off;
}

server {
	listen 443 ssl;
	server_name xxx;
	ssl_certificate /opt/nginx_certificate2/_.xxx_bundle.crt;
	ssl_certificate_key /opt/nginx_certificate2/xxx_RSA.key;
	ssl_session_timeout 5m;
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;
	root /home/static/windows-prod;
    underscores_in_headers on;

	    location / {
	        index index.html;
            try_files $uri $uri/ @router;		
	    }

        location /test {
            alias /home/static/windows;
            index index.html;
            try_files $uri $uri/ @router;
        }

	    location @router{
            rewrite ^.*$ /index.html last;
        }
}