百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>html5教程> nginx配置拜访图片途径以及html静态页面的调用办法
分享文章到:

nginx配置拜访图片途径以及html静态页面的调用办法

发布时间:09/01 来源:未知 浏览: 关键词:
这篇文章主要介绍了详解nginx配置拜访图片途径乃至html静态页面的调取办法,此刻分享给大家,也给大家做个参照 。

给大家讲一个快速配置nginx拜访图片地址,乃至拜访html静态页面的配置。

1.实验环境

第一随意某个途径下创立响应的名目。如图下

2.在里面放自定义的html或者图片。

3.nginx配置

user root;  
worker_processes 1;  
  
#error_log logs/error.log;  
#error_log logs/error.log notice;  
#error_log logs/error.log info;  
  
#pid    logs/nginx.pid;  
  
  
events {  
  worker_connections 1024;  
}  
  
  
http {  
  include    mime.types;  
  default_type application/octet-stream;  
  
  log_format main '$remote_addr - $remote_user [$time_local] "$request" '  
           '$status $body_bytes_sent "$http_referer" '  
           '"$http_user_agent" "$http_x_forwarded_for"';  
  
  access_log logs/access.log main;  
  
  sendfile    on;  
  #tcp_nopush   on;  
  
  #keepalive_timeout 0;  
  keepalive_timeout 65;  
  
  #gzip on;  
  
  
  server {  
    listen    80;#端标语  
    server_name localhost;#本机  
  
    charset utf-8;  
  
    #access_log logs/host.access.log main;  
  
  location ~ .*\.(gif|jpg|jpeg|png)$ {  
    expires 24h;  
      root /home/images/;#指定图片存置途径  
      access_log /usr/local/websrv/nginx-1.9.4/logs/images.log;#日志存置途径  
      proxy_store on;  
      proxy_store_access user:rw group:rw all:rw;  
      proxy_temp_path     /home/images/;#图片拜访途径  
      proxy_redirect     off;  
      proxy_set_header    Host 127.0.0.1;  
      client_max_body_size  10m;  
      client_body_buffer_size 1280k;  
      proxy_connect_timeout  900;  
      proxy_send_timeout   900;  
      proxy_read_timeout   900;  
      proxy_buffer_size    40k;  
      proxy_buffers      40 320k;  
      proxy_busy_buffers_size 640k;  
      proxy_temp_file_write_size 640k;  
      if ( !-e $request_filename)  
      {  
         proxy_pass http://127.0.0.1;#默许80端口  
      }  
  }   
  
    location / {  
      root  /home/html; #html拜访途径 
      index index.html index2.htm; #html文件名称 
 
    } 
  
    error_page 404       /404.html; </span>

4.查看编译可否有出错,假如没出错则设定成功。

5.拜访nginx则能拜访到拜访的图片地址。

6.拜访自定义html时。

成功。

以上就是本文的全部内容,但愿对大家的学习有所帮忙,更多相关内容请关注PHP中文网!

以上就是nginx配置拜访图片途径乃至html静态页面的调取办法的具体内容,更多请关注百分百源码网其它相关文章!

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有150人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板