当前位置: 首页 > article >正文

docker 安装部署 nginx

命令

docker run \
-p 15008:80 \
--name nginx1.21.6 \
-v /iepms/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /iepms/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /iepms/nginx/log:/var/log/nginx \
-v /iepms/nginx/html:/usr/share/nginx/html \
-d 192.168.1.103/base/nginx:1.26.1

nginx 配置文件


#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;
	
	#include       ./conf/include/blackIP.conf;
	include       D:/tool/nginx/nginx-1.26.1/conf/include/blackIP.conf;
	
	client_max_body_size 10m;
	client_body_buffer_size 10m;

    #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
	gzip  on;  
	#低于1kb的资源不压缩 
	gzip_min_length 1k;
	#压缩级别1-9,越大压缩率越高,同时消耗cpu资源也越多,建议设置在5左右。 
	gzip_comp_level 5; 
	#需要压缩哪些响应类型的资源,多个空格隔开。不建议压缩图片.
	#gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;  
	#配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
	gzip_disable "MSIE [1-6]\.";  
	#是否添加“Vary: Accept-Encoding”响应头
	gzip_vary on;
	gzip_types
    	application/atom+xml
    	application/javascript
    	application/json
    	application/ld+json
    	application/manifest+json
    	application/rss+xml
    	application/vnd.geo+json
    	application/vnd.ms-fontobject
    	application/x-font-ttf
    	application/x-web-app-manifest+json
    	application/xhtml+xml
    	application/xml
    	font/opentype
    	image/bmp
    	image/svg+xml
    	image/x-icon
    	text/cache-manifest
    	text/css
    	text/plain
    	text/vcard
    	text/vnd.rim.location.xloc
    	text/vtt
    	text/x-component
    	text/x-cross-domain-policy;
	
	# 代理服务器
	upstream backend {
		ip_hash;
		server localhost:8089 max_fails=1000 weight=1;
		server localhost:8088 weight=1000;
	}

    server {
        listen       80;
        server_name  127.0.0.1;

		server_name_in_redirect on;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/;
            index  index.html index.htm;
        }
		
        #location /image {
        #    root   html/;
        #    index  index.html index.htm;
        #}
		
		#location /image {
        #    root   html/;
		#	try_files $uri $uri/ /image/default.jpg; 
        #}
		
		location ~* \.(gif|jpg|jpeg|png|bmp)$ {  
			valid_referers 127.0.0.1;
			if ($invalid_referer) {
				return 403;
				#可以配置成返回一张禁止盗取的图片
				#rewrite ^/ https://xxxxxxxxxxx
			}  
		}
		
		location /api {
			proxy_set_header   X-Real-IP        $remote_addr;
			proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_set_header   Host             $http_host;
			proxy_set_header   X-NginX-Proxy    true;
			proxy_set_header   Connection "";
			proxy_http_version 1.1;
			add_header Access-Control-Allow-Origin *;
			proxy_pass http://backend/;
        }  
		
		location /iepms_web_test {
			root   html/;
			proxy_pass http://192.168.1.126:16008/iepms_web/;
			try_files $uri $uri/ /iepms_web/default.jpg; 
        }  
		
		location /gateway/ {
			proxy_hide_header X-Frame-Options;
			add_header X-Frame-Options ALLOWALL;
			proxy_pass http://127.0.0.1:15000;
		}
        #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;
    #    }
    #}

}


http://www.kler.cn/a/369714.html

相关文章:

  • Ubuntu-手动安装 SBT
  • 【新春特辑】2025年1月科技浪潮中的AI最新时事与科技趋势
  • 【编译原理实验二】——自动机实验:NFA转DFA并最小化
  • 深入理解Pytest中的Setup和Teardown
  • 大屏 UI 设计风格的未来趋势
  • LTV预估 | 深度学习PLTV之开山鼻祖ZILN
  • SPA和SSR
  • 构造+置换环,CF 1983D - Swap Dilemma
  • 计算机网络:网络层 —— IP数据报的发送和转发过程
  • php伪协议和move_uploaded_file、rename、copy等文件操作
  • 【python】OpenCV—WaterShed Algorithm(1)
  • 控制卸载/安装应用
  • Chromium HTML5 新的 Input 类型date 对应c++
  • C++基于opencv的视频质量检测--画面冻结检测
  • Vue3中ref、toRef和toRefs之间有什么区别?
  • 基于SSM+微信小程序的快递的管理系统(快递1)
  • 基于脚手架创建前端工程
  • Linux 应用领域
  • 老电脑不能装纯净版windows
  • GEE APP:加载Landsat TOA数据可视化界面,实现点击提取ndvi值
  • 云原生后端开发教程
  • Python实现微博舆情分析的设计与实现
  • 存储服务器通常适用于哪些应用场景?
  • Spring版本有哪些
  • 回溯算法习题其二-Java【力扣】【算法学习day.16】
  • 外包功能测试就干了4周,技术退步太明显了。。。。。