1. 程式人生 > >FTP+Nginx圖片伺服器(整合)

FTP+Nginx圖片伺服器(整合)

其實就是配置nginx.config

nginx的訪問路徑配置成sftp存放資源的路徑

一開始有可能啟動成功但是nginx不能訪問,這時候我們關閉下linux的防火牆

防火牆有firewalliptables兩種,你看看是哪個關了就行,當然或者配置下防火牆的埠也可以

nginx.config/usr/local/nginx/conf

更改完了先停止nginx然後在根據conf啟動,詳見上篇部落格,下面是配置資訊

user  root;
worker_processes  1;
worker_rlimit_nofile 65535;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  12040;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
	#Proxy_cache_path    /data/sftp/usersftp/upload levels=1:2  keys_zone=cache_one:200m inactive=1d max_size=30g;

    #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       8088;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
			#proxy_pass http://192.168.10.223:1234;
        }

        #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       7788;
        server_name  localhost;
	#    ssl on;
    #    ssl_certificate      /usr/local/nginx/conf/server.crt;
    #    ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;

	charset utf-8;
	#charset koi8-r;
	
	location ~ (\.jsp)|(\.do)/ {
		proxy_pass http://127.0.0.1:7001;
		proxy_set_header X-Real-IP $remote_addr;
		
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_buffer_size 4k;
		proxy_buffers 4 32k;
		proxy_busy_buffers_size 64k;
		proxy_temp_file_write_size 64k;
		proxy_max_temp_file_size 512m;
      }
    }
	
	server {
			listen 8888;
			server_name localhost;
		
		charset utf-8;
		
			location ~ .*\.(gif|jpg|jpeg|png){
				#allow 127.0.0.1;
				#deny all;
				
				#expires 24h;
					root /data/sftp/usersftp/upload;
					access_log /usr/local/nginx/NginxTestImgLog/log_test.log;
					proxy_store on;
					proxy_store_access user:rw group:rw all:rw;
					
					proxy_redirect    off;
					
					proxy_set_header  Host $host;
					proxy_set_header  X-Real-IP $remote_addr;
					proxy_set_header  X-Forwarded-For $remote_addr;
					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          1024k;
					proxy_buffers              40 1024k;
					proxy_busy_buffers_size    1024k;
					proxy_temp_file_write_size 1024k;
				proxy_temp_path    /usr/local/nginx/nginxTestImg/;
				#Proxy_cache_path /nginxTestImg/;
				if ( !-e $request_filename)
					{
				proxy_pass http://127.0.0.1:8888;
					}
					
			}
			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;
			}
			
		
	}

}

下篇部落格就是從html利用表單提交到springMVC 到controller到service然後到sftp