使用寶塔面板 配置nginx 訪問ftp服務器下面的圖片


如果 你在服務器上 運行war項目 可以在tomcat 配置訪問的:

tomcat 也貼出來吧!

 

一.tomca配置訪問,需要更改配置文件server.xml ,如果找不到,自己好好找一下  一般在 tomcat/conf 這個目錄下面

 

1.

截圖:

 

 2.

 

 3.找到 <Host></Host> 這個標簽

然后在<Host></Host>里添加<Context></>來實現映射功能

 

 添加這一段:

 

 直接放出來,你們可以復制

 <Context path="/img" docBase="/img"  reloadable="true"></Context>

 

然后就可以訪問一下啦,圖片訪問成功

 

 

 

 

二 .配置nginx 訪問ftp圖片

1:進入配置文件的目錄:

 

2;nginx的默認配置文件nginx.config

#user  nobody;  
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 koi8-r;  

        #access_log  logs/host.access.log  main;  

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;  

        # redirect server error pages to the static page /50x.html  
        #  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80  
        #  
        #location ~ \.php$ {  
        #    proxy_pass   http://127.0.0.1;  
        #}  

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
        #  
        #location ~ \.php$ {  
        #    root           html;  
        #    fastcgi_pass   127.0.0.1:9000;  
        #    fastcgi_index  index.php;  
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
        #    include        fastcgi_params;  
        #}  

        # deny access to .htaccess files, if Apache's document root  
        # concurs with nginx's one  
        #  
        #location ~ /\.ht {  
        #    deny  all;  
        #}  
    }


    # another virtual host using mix of IP-, name-, and port-based configuration  
    #  
    #server {  
    #    listen       8000;  
    #    listen       somename:8080;  
    #    server_name  somename  alias  another.alias;  

    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  


    # HTTPS server  
    #  
    #server {  
    #    listen       443 ssl;  
    #    server_name  localhost;  

    #    ssl_certificate      cert.pem;  
    #    ssl_certificate_key  cert.key;  

    #    ssl_session_cache    shared:SSL:1m;  
    #    ssl_session_timeout  5m;  

    #    ssl_ciphers  HIGH:!aNULL:!MD5;  
    #    ssl_prefer_server_ciphers  on;  

    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  

}

三:配置圖片服務器

方法一、在配置文件server{}中location /{} 修改配置:

   #默認請求  
  location / {
     root  /home/ftpuser/www;#定義服務器的默認網站根目錄位置  
     index index.html index.php index.htm;#定義首頁索引文件的名稱  
   }

 

截圖:

 

測試:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM