vim编辑nginx.conf,在server里面添加一个location
location /images/{
root /usr/local/;
autoindex on;
}
注意:root后面的路径加上location后面的路径就是图片目录的绝对路径
我的图片目录是:/usr/local/images
server {
listen 443 ssl;
server_name api.chenlilin.cn;
ssl_certificate cll-api.pem;
ssl_certificate_key cll-api.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#location / {
# root html;
# index index.html index.htm;
#}
#location /{
# proxy_pass http: //localhost:8080/;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded_For $remote_addr;
#}
location /{
root /usr/local/nginx/www;
proxy_pass https://localhost:9010;
#root html;
index index.html index.htm;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
}
location /images/{
root /usr/local/;
autoindex on;
}
}
编辑完成之后重启nginx就可以了
这是我的个人博客,欢迎访问https://www.chenlilin.cn/