docker nginx

2018-07-24  本文已影响0人  IT追梦人

docker run -p 8080:80 --name nginx_web -v /opt/gnss/nginx/html:/usr/share/nginx/html -v /opt/gnss/nginx/log:/var/log/nginx -v /opt/gnss/nginx/nginx.conf/:/etc/nginx/nginx.conf -v /opt/gnss/nginx/conf.d/:/etc/nginx/conf.d:rw -d nginx

在/opt/gnss/nginx/conf.d新增default.conf

server {

    listen      80;

    server_name  localhost;

    #charset koi8-r;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {

        root  /usr/share/nginx/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  /usr/share/nginx/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;

    #}

    location /gnss-admin/api/ {

        proxy_redirect off; 

        proxy_set_header Host $host; 

        proxy_set_header X-Real-IP $remote_addr; 

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_pass http://172.17.0.1:8088/gnss-admin/api/;

    }

}

#安装vim

apt-get update

apt-get install vim

开启gzip压缩,vi nginx.conf:

gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 16k;

  #gzip_http_version 1.0;

    gzip_comp_level 2;

    gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

    gzip_vary off;

    gzip_disable "MSIE [1-6]\.";

上一篇下一篇

猜你喜欢

热点阅读