我仍然在学习nginx配置。我目前可以使用以下块通过AWS中的ALB代理S3中的一些UI文件。不过,我在设置位置路径时遇到了问题。
我只能在以下位置访问角度应用程序:https://domainname/index.html
我需要的是访问https://domainname/appname
上的UI文件,然后从那里加载所有文件。我该怎么做?这是我当前的nginx.conf文件。
server {
listen 80;
server_name <servername>.com;
resolver 8.8.8.8 valid=30s;
index index.html;
gzip_types text/plain application/xml application/x-javascript text/css application/json text/javascript;
location ~* ^/(.*) {
set $S3BUCKET "<bucketnamepassedinhere>.s3.amazonaws.com";
proxy_buffering off;
proxy_ignore_headers "Set-Cookie";
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-s3cmd-attrs;
proxy_hide_header Set-Cookie;
proxy_set_header Host $S3BUCKET;
proxy_set_header Connection "";
proxy_intercept_errors on;
proxy_pass https://$S3BUCKET/$1;
break;
}
}
检查这个:
server {
listen 80;
location / {
proxy_buffering off;
proxy_set_header Connection "";
proxy_set_header Authorization '';
proxy_set_header Host humtydumty.dev.s3.amazonaws.com;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-server-side-encryption;
proxy_hide_header x-amz-server-side-encryption;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
proxy_intercept_errors on;
add_header Cache-Control max-age=31536000;
proxy_pass http://humtydumty.dev.s3.amazonaws.com;
}
希望这个答案对你有帮助!