My Nginx配置

这篇博客详细介绍了Nginx的配置结构,包括主要的nginx.conf文件,以及http和stream模块下的不同配置文件,如location_http.conf、location_https.conf、proxy.conf和stream.conf。此外,还提到了rtmp服务器的servers.conf配置,展示了如何设置和管理HTTP、HTTPS及流媒体服务。
摘要由CSDN通过智能技术生成

nginx.conf

#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;#单个进程的最大连接数 (最大连接数=连接数*进程数)
}
stream {
   
	include module/stream/*.conf; 
}
http {
   
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" ';
    log_format main2	'[$time_local]'
						' $remote_addr $http_x_forwarded_for $remote_user $http_referer $http_user_agent'
						' "$request" $status $body_bytes_sent $bytes_sent $request_length'
                        ' [$request_time]--[$upstream_response_time]';
	 log_format testLog	'$remote_addr [$time_local]'
						'$http_host | $Host|$proxy_host'
						'	$proxy_port| $server_port';

    #'"$http_user_agent" "$http_x_forwarded_for"';
	open_log_file_cache max=1000 inactive=60s;
    #access_log  logs/access.log  main; 
    sendfile        on;
    #tcp_nopush     on; 
     
	keepalive_timeout 60s;	 #长连接timeout
    keepalive_requests 8192; #每个连接最大请求数
    #gzip  on; 
	include module/httpsvr/*.conf;
}
rtmp {
    
	include module/rtmpsvr/*.conf;
}

conf\module\ex

location_http.conf

			proxy_set_header Host $host:$server_port;#$http_host | $Host==$host  |$proxy_host
			#$proxy_port 前端代理的端口
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-Proto  $scheme;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Via "nginx";
			proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
			proxy_cache_bypass $http_pragma $http_authorization;
			proxy_no_cache $cookie_nocache $arg_nocache $arg_comment;
			proxy_no_cache $http_pragma $http_authorization;
			
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
			proxy_send_timeout 600;
			
			#proxy_buffer_size 4k;
			#proxy_buffers 6 128k;
			#proxy_busy_buffers_size 256k;
			#proxy_temp_file_write_size 256k;
			
		 
			
			
			#proxy_store off;
			#proxy_redirect off;
			#proxy_http_version 1.1;
			#proxy_set_header Upgrade $http_upgrade;
			#proxy_set_header Connection "upgrade";	#"upgrade" | ""; 
			#proxy_set_header Origin "";
			#proxy_pass_header Server;
			#proxy_redirect off;
			#client_max_body_size 10m;
			#client_body_buffer_size 128k;
			
			#proxy_set_header "Host" $host:28081;#不可缺少否则ngrok 反向代理不通
			#if ( $host  ~* (.*)\.ngrok\.(.*) )
			#{
   
			#	#代理失败不知道原因,改用重定向
			#	#proxy_pass  http://$host:28081;
			#	#rewrite  ^(.*)$   http://$host:28081 permanent;
			#	proxy_pass http://127.0.0.1:28081;
			#	break;
			#} 
			
			#add_header Cache-Control no-store;
            #add_header Pragma  no-cache; 
			#add_header Access-Control-Allow-Origin *; 
			#expires -1;
			
			#types {  
			#	application/vnd.apple.mpegurl m3u8;  
			#	video/mp2t ts; 
			#}  

location_https.conf

			proxy_redirect http:// https://; 
			proxy_set_header Host $host:$server_port;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header X-Forwarded-Proto  $scheme;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Via "nginx";
			proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment;
			proxy_cache_bypass $http_pragma $http_authorization;
			proxy_no_cache $cookie_nocache $arg_nocache $arg_comment;
			proxy_no_cache $http_pragma $http_authorization;
			
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
			proxy_send_timeout 600; 

httpsvr

upserver.conf

	upstream abc.com{
   
		server 127.0.0.1:9666 weight=5 max_fails=2 fail_timeout=30s max_conns=3
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ynchyong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值