rancher安装nginx规则 rancher


安装nginx:

nginx
nginx:latest
命令:
nginx -g daemon off;
添加卷:
/data/site:/data/site:ro
/data/soft:/data/soft
/data/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
/data/docker/nginx/logs:/var/log/nginx
/data/docker/nginx/conf.d:/etc/nginx/conf.d:ro

vi /data/docker/nginx/nginx.conf

user  nginx;
worker_processes  16;
worker_rlimit_nofile 1048576;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    use epoll;
    worker_connections  10240;
}
http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 1024m;
  client_body_buffer_size 10m;
  sendfile on;
  tcp_nopush on;
  keepalive_timeout 120;
  server_tokens off;
  tcp_nodelay on;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
  fastcgi_intercept_errors on;
  #Gzip Compression
  gzip on;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
  gzip_http_version 1.1;
  gzip_min_length 256;
  gzip_proxied any;
  gzip_vary on;
  gzip_types
    text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
    text/javascript application/javascript application/x-javascript
    text/x-json application/json application/x-web-app-manifest+json
    text/css text/plain text/x-component
    font/opentype application/x-font-ttf application/vnd.ms-fontobject
    image/x-icon;
  gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  #If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
  open_file_cache max=1000 inactive=20s;
  open_file_cache_valid 30s;
  open_file_cache_min_uses 2;
  open_file_cache_errors on;
  include /etc/nginx/conf.d/*.conf;
}

宿主机上添加test.cndo.org域名配置:

server {
    listen       80;
    server_name  www.ycboo.com *.ycboo.com;
    charset utf-8; 
    access_log  /var/log/nginx/www.ycboo.com.access.log  main;
    error_page  404 500 502 503 504  /50x.html;
    location = /50x.html {
        root   /data/site/default;
    }
    location / {
        root   /data/site/www/www.ycboo.com;
        index  index.html index.htm index.php;
        if (-f $request_filename) {
           break;
           }
        if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {
           break;
           }
        if (!-e $request_filename) {
           rewrite . /index.php last;
           }
    }
    location ~ \.php$ {
        root /data/site/www/www.ycboo.com;
        try_files $uri =404;
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 2 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
    location ~ /\.ht {
      deny all;
    }
}
##开启nginx
service nginx start
访问测试: http://test.cndo.org/


签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回