[nginx]安装配置(ubuntu/windows)

/ 7评论 / 581阅读 / 1点赞

nginx

这是一个使用c发高性能免费开源软件,被用于网络中的负载均衡,端口转发,反向代理等。

我常用它来监听80端口中的http请求,通过判断这些http请求的域名,


ubuntu环境


下载安装nginx


编写server配置文件

直接由nginx提供服务

server {
        listen       80;                  #监听端口
        server_name  www.coolight.cool;   #域名
        #-------nginx----------
        location / {                      #链接的后半部分为空时
           root /home/0Acoolight/nginx/root;  #访问的文件所在目录
           index index.html index.htm;        #访问的文件名
        }

        location /hello {
           root /home/0Acoolight/nginx/root/hello;  #访问的文件所在目录
           index index.html index.htm;        #访问的文件名
        }
}

nginx提供php服务


nginx转发给其他端口

server {
        listen       80;
        server_name  tomcat.coolight.cool;
        #-------Tomcat---------
        location / {
            proxy_pass  http://localhost:8080/;

            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            
            client_max_body_size 10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
}

Win环境

下载安装nginx

server {
        listen       80;
        server_name  tomcat.coolight.cool;
        #-------Tomcat---------
        location / {
            proxy_pass  http://localhost:8080;
            proxy_set_header        Host            $host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size 10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
}

常用命令


常见问题

  1. Injeway说道:

    cheapest cialis 20mg 1 307 1 271 1 250 1 200 1 200 1 188 1 187 1 122 1 122 1 122 1 113 1 109 1 056 1 030 1 000 1 000 89 000 10 000 6 000 5 547

  2. VORVOSESK说道:

    After subgroup analysis and sensitivity analysis, we found that Cristofanilli s research may cause heterogeneity 23 viagra nitric oxide Nondestructive determination of lignans and lignan glycosides in sesame seeds by near infrared reflectance spectroscopy

  3. VORVOSESK说道:

    ERОІ1 repressed the mesenchymal spindle shaped morphology of the MDA MB 231 and Hs578T cells and enhanced cell cell contact buy cialis 5mg This would be my first, so I don t know what to expect

  4. Injeway说道:

    In specific population such as cigarette smokers the use of ОІ carotene increases the risk of lung or prostate cancer 205, 206, 207, 212 cialis 20mg I knew about misoprostol before I miscarried specifically that it s not FDA- approved for use on pregnant women, but doctors continue to use it to induce labor, and that it often results in ruptured uteruses

  5. Great online game https://razorsharkplay.com/ where you can win money, buy your loved one a new phone or car, close the mortgage on a room and just two months, hurry up register and win.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注