Skip to content

Instantly share code, notes, and snippets.

@qlong8807
Created November 22, 2019 07:25
Show Gist options
  • Save qlong8807/16a99916fe87b8af1b72dab609ae8963 to your computer and use it in GitHub Desktop.
Save qlong8807/16a99916fe87b8af1b72dab609ae8963 to your computer and use it in GitHub Desktop.
nginx发布静态页面,nginx做图片服务器 配置。一个文件中可以写多个server。
server {
listen 8081;
server_name 10.255.203.162;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root C:\Users\zyl\Documents\Axure\HTML;
try_files $uri $uri/ @router;
index index.html start.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ \.(gif|jpg|jpeg|png|bmp|swf)$ {
#把图片放到该路径下,访问http://localhost/1.png即可。
root E:/tools/imageserver/www;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
修改完成后,用nginx -t验证配置文件,使用nginx -s reload重新加载配置文件。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment