1 搭建好nginx,可以使用
2 在nginx.conf配置文件中,對http模塊,server模塊修改,增加一個location
location /esIndex/ {
root html;
rewrite ^//(.*)$ \$1 break;
}
3 sbin/nginx -t,sbin/nginx -s reload,重載一下nginx配置文件。
4 在nginx/html文件夾中,新建一個文件夾esIndex,創建一個文件test.info,里邊寫入一些測試內容。然后訪問路徑:http://ip+端口/esIndex/test.info,其中ip和端口為nginx的ip和監聽的端口,就可以通過nginx訪問esIndex文件夾下的內容。
5 其實不用創建esIndex文件夾,直接在html文件夾中創建esIndex.info,訪問http://ip+端口/esIndex.info,也可以。
下面是nginx.conf配置:
http { include mime.types; default_type application/octet-stream; sendfile on; server_tokens off; keepalive_timeout 75; gzip on; client_max_body_size 100m; #client_body_buffer_size 4096k; client_body_buffer_size 20m; proxy_connect_timeout 600; proxy_read_timeout 300; proxy_send_timeout 600; proxy_buffer_size 128k; proxy_buffers 32 128k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 512k; proxy_next_upstream http_500 http_502 http_503 error invalid_header; proxy_temp_path /home/zyzx_test/nginx/proxy_temp; proxy_cache_path /home/zyzx_test/nginx/proxy_cache levels=1:2 keys_zone=cache_one:100m inactive=2d max_size=2g; server { listen 22022; server_name localhost; location /esIndex/ { root html; rewrite ^//(.*)$ \$1 break; } } }
