nginx代理web应用&负载配置&nginx日志配置


user  dev;
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;

   #日志格式配置 

   log_format  main  '$remote_addr - $remote_user [$time_local] "$request" 实际请求地址[$upstream_addr] '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

 #日志变量说明

$remote_addr 客户端地址    211.28.65.253

$remote_user  客户端用户名称                                --

$time_local  访问时间和时区 8/Jul/2012:17:00:01 +0800

$request 请求的URI和HTTP协议 "GET /article-10000.html HTTP/1.1"

$http_host 请求地址,即浏览器中你输入的地址(IP或域名) www.wang.com 192.168.100.100

$status HTTP请求状态  200

$upstream_status upstream状态   200

$body_bytes_sent 发送给客户端文件内容大小 1547

$http_referer url跳转来源 https://www.baidu.com/

$http_user_agent 用户终端浏览器等信息  "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C;

$ssl_protocol SSL协议版本 TLSv1

$ssl_cipher 交换数据中的算法  RC4-SHA

$upstream_addr 后台upstream的地址,即真正提供服务的主机地址     10.10.10.100:80

$request_time  整个请求的总时间                               0.205

$upstream_response_time  请求过程中,upstream响应时间                    0.002

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   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   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;
    #    }
    #}

   # nginx代理web应用&负载配置
    upstream bframe {
     # ip_hash;
      server 192.168.0.139:8081; 
      server 192.168.0.139:8091; 
    }
    
    server {
        listen       8888;

       #控制文件上传大小

        client_max_body_size 500M;
        server_name  localhost;
        location / {
            proxy_pass http://bframe;  
            proxy_redirect default;
            #nginx支持websocket消息推送需要增加以下三条配置
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Origin "";
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Nginx是一款高性能的开源Web服务器和反向代理服务器。在Windows操作系统上配置Nginx主要涉及以下几个方面: 1. 下载和安装Nginx:在Nginx官方网站上,我们可以下载到适用于Windows操作系统的Nginx安装程序。下载完成后,双击安装程序进行安装,按照提示进行相关配置,比如选择安装目录等。 2. 配置Nginx配置文件:Nginx的主配置文件是nginx.conf。可以用文本编辑器打开该文件进行配置。其中,常见的配置项包括监听端口、服务器名称、日志文件路径、代理配置和访问控制等。 3. 配置虚拟主机:Nginx支持虚拟主机的配置。在虚拟主机配置中,我们可以指定不同的域名或IP地址对应的不同主机。配置虚拟主机可以实现多个网站或应用在同一台服务器上运行,提高服务器的利用率。 4. 配置反向代理Nginx可以作为反向代理服务器,将客户端请求转发到后端的其他服务器。通过反向代理,可以实现负载均衡、缓存加速、SSL终端等功能。在配置文件中,我们可以设置代理服务器的地址和端口,并定义代理规则。 5. 配置HTTPS:如果要在Nginx上启用HTTPS协议,我们需要生成SSL证书,并将证书路径配置Nginx配置文件中。此外,还需要配置HTTPS监听端口以及相关的加密算法和SSL选项。 6. 启动和重启Nginx:在配置完成后,我们可以使用命令行工具或者点击桌面快捷方式启动Nginx服务。同时,可以使用命令行工具执行nginx -s reload命令,实现对Nginx的重启,使得配置生效。 总之,通过以上步骤,我们可以在Windows操作系统中成功配置Nginx,并实现Web服务器和反向代理服务器的功能。当然,具体的配置还需要根据具体的需求和环境来决定。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

zhong_jianyu

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

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

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

打赏作者

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

抵扣说明:

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

余额充值