Linux操作文档之nginx域名解析(一)

本文详细介绍了Nginx服务器的配置方法,包括如何创建并配置conf.d文件夹下的xxx.conf文件,具体涉及监听端口、域名配置、日志输出、缓存设置等内容,并展示了如何在nginx.conf中整合所有配置。

创建 conf.d 文件夹,创建 xxx.conf 文件,并配置如下


server {

	listen       80;
	server_name  xxx.com;    //配置域名

    access_log  /log/nginx/ad.v.stock.com.log  main;	

    location ~ ^/aaa/bbb/(.*)$ {
		alias /data/sc/plat/bbb/$1;
		access_log on;       //设置日志输出
		expires 24h;           //设置时间
	}

    location ~*.* {
		proxy_pass http://localhost:28030;     //项目访问端口
	}	
    
    //设置请求头
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

配置 nginx.conf


worker_processes  1;

error_log  /log/nginx/error.log;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    charset  utf-8;

	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  /log/nginx/access.log  main;

    server_names_hash_bucket_size 256;
	client_header_buffer_size 4k;
	large_client_header_buffers 4 8k;
	client_body_buffer_size 256k;
	client_max_body_size 8m;
	client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;

	open_file_cache max=20480 inactive=20s;
	open_file_cache_valid 30s;
	open_file_cache_min_uses 1;

	keepalive_timeout  120;

	tcp_nopush on;
	sendfile on;
	tcp_nodelay on;

	gzip on;
	gzip_min_length   1k;
	gzip_buffers      8 64k;
	gzip_http_version 1.0;
	gzip_comp_level   2;
	gzip_disable      "msie6";
	gzip_types        text/plain application/x-javascript text/css application/xml;
	gzip_vary on;
	
	proxy_redirect off;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $host;	
	proxy_set_header referer $http_referer;
	proxy_connect_timeout 60;
	proxy_send_timeout 60;
	proxy_read_timeout 60;
	proxy_buffer_size 256k;
	proxy_buffers 8 256k;
	proxy_busy_buffers_size 256k;
	proxy_temp_file_write_size 256k;

	#limit_req_zone  $binary_remote_addr  zone=one:10m   rate=5r/s;

	# Load config files from the /etc/nginx/conf.d directory
	include conf.d/*.conf;

}



转载于:https://my.oschina.net/Xangyu/blog/817965

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值