Nginx开启https和代理转发

296 阅读1分钟

server {
    listen 443 ssl;
    server_name eee.cc www.eee.cc 34.22.2.33;

    ssl_certificate /www/fullchain.pem;
    ssl_certificate_key /www/privkey.key;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
    ssl_prefer_server_ciphers on;

     location /prod-api/ {
      rewrite ^/prod-api(/.*)$ $1 break;
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://localhost:8081/;
		}
		
		  location /api/ {
                     rewrite ^/api(/.*)$ $1 break;		
                     proxy_pass http://w1.luyouxia/;
		}
		 location /file/ {
                    rewrite ^/file(/.*)$ $1 break;		
                    proxy_pass http://e3.luyouxia:12956/;
		}
		
		
    location / {
      root /www/wwwroot/default/dist;
      index index.html;
        # try_files $uri $uri/ /index.html;
    }

    # 配置其他静态资源的缓存等,可根据实际需要添加
    # location ~* \.(css|js|gif|jpe?g|png)$ {
    #     expires 1y;
    #     add_header Cache-Control "public, max-age=31536000";
    #     access_log off;
    # }
   location ~ /assets/ {
    root /www/wwwroot/default/dist/;
      expires 1y;
      add_header Cache-Control "public, max-age=31536000";
      access_log off;
    }
    # 配置 Gzip 压缩
    # gzip on;
    # gzip_min_length 1000;
    # gzip_types application/json application/javascript text/css;
}