【发布时间】:2017-05-23 03:00:53
【问题描述】:
我在 apache 前面运行 nginx 作为反向代理服务器。 我需要从后端的前端访问上传的文件,所以要走的路是在 nginx 站点配置中使用别名,但后端的静态文件应该由 nginx 直接处理。我是 nginx 新手,所以这是我处理静态文件的部分配置。我还指定了一个别名 (/images),但它不起作用,因为它被第二个条件覆盖。 如何将这两个条件结合起来,以便 nginx 处理来自根(后端应用程序)的静态文件和从前端应用程序上传的文件。 在 apache 配置中,我为这个问题添加了一个别名,它可以工作,但前面没有 nginx。
这是我的部分 nginx 配置:
server {
listen 80;
root /var/www/website/backend/www;
# Add index.php to the list if you are using PHP
index index.html index.php index.htm;
server_name admin.website.com www.admin.website.com;
location / {
proxy_pass http://localhost:8080;
include /etc/nginx/proxy_params;
}
#The alias to handle uploaded files(.jpeg, .pdf) from frontend
location /images {
alias /var/www/website/frontend/www/images;
}
#let nginx handle static files from root
location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
expires 30d;
}
.
.
.
}
【问题讨论】:
标签: nginx