ngnix的Windows版本可用的最基本文件配置

简介: ngnix的Windows版本可用的最基本文件配置
#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;
    #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  on;
#设定负载均衡的服务器列表
#weigth参数表示权值,权值越高被分配到的几率越大
upstream mytest{
    server x.x.x.x:8080 weight=1;
    server x.x.x.x:8080 weight=1;            
}
    server {
        listen       8000;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            #root   html;
            #index  index.html index.htm;
        proxy_pass http://mytest;
        }
        #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;
    #    }
    #}
}

其中重点是: proxy_pass http://mytest;   mytest是定义了两个服务器,用作负载均衡。

proxy_pass  是转发的路径;

其中后面是否加符号/的区别是:

如果后面加了 /;表示proxy_pass后面的URL就是绝对路径

如果后面没有加/;表示proxy_pass的URL是相对路径,需要加上location 后面匹配的字符串(若有)。

以上是ngnix的Windows版本可用的最基本文件配置!

相关文章
|
4天前
|
Windows
LabVIEW安装程序需要Windows1064位(版本1507)或更新版本
LabVIEW安装程序需要Windows1064位(版本1507)或更新版本
11 1
|
4天前
|
Java 程序员 Windows
【windows自带exe】使用`findstr.exe`来搜索包含某个字符串的文件
【windows自带exe】使用`findstr.exe`来搜索包含某个字符串的文件
10 0
|
4天前
|
编解码 Windows
LabVIEW应用程序在Windows版本之间的字体变化
LabVIEW应用程序在Windows版本之间的字体变化
10 1
|
5天前
|
并行计算 Windows
23.10.02更新 Windows下CUDA和CUDNN的安装和配置(图多详细)
23.10.02更新 Windows下CUDA和CUDNN的安装和配置(图多详细)
14 1
|
7天前
|
安全 Linux 网络安全
Windows搭建Emby媒体库服务器,无公网IP远程访问本地影音文件
Windows搭建Emby媒体库服务器,无公网IP远程访问本地影音文件
17 0
|
10天前
|
Oracle Java 关系型数据库
windows 下 win11 JDK17安装与环境变量的配置(配置简单详细,包含IJ中java文件如何使用命令运行)
本文介绍了Windows 11中安装JDK 17的步骤,包括从官方网站下载JDK、配置环境变量以及验证安装是否成功。首先,下载JDK 17的安装文件,如果没有Oracle账户,可以直接解压缩文件到指定目录。接着,配置系统环境变量,新建`JAVA_HOME`变量指向JDK安装路径,并在`Path`变量中添加。然后,通过命令行(cmd)验证安装,分别输入`java -version`和`javac -version`检查版本信息。最后,作者分享了如何在任意位置运行Java代码,包括在IntelliJ IDEA(IJ)中创建的Java文件,只需去掉包声明,就可以通过命令行直接运行。
|
13天前
|
安全 数据安全/隐私保护 Windows
Windows文件搜索神器Everything安装配置结合内网穿透实现公网查询本地文件
Windows文件搜索神器Everything安装配置结合内网穿透实现公网查询本地文件
|
13天前
|
Apache 项目管理 数据安全/隐私保护
Windows安装TortoiseSVN客户端结合Cpolar实现公网提交文件到本地服务器
Windows安装TortoiseSVN客户端结合Cpolar实现公网提交文件到本地服务器
|
14天前
|
Unix Shell 开发工具
windows下如何安装git以及IDEA如何配置git
该文指导安装Git 2.15.0版本。首先从Git官网下载最新安装包,双击安装,依次选择Next,同意默认配置,确保勾选添加到环境变量。在配置选项中,选择在cmd中使用Git(第2项),行结束转换选Windows(第1项),终端模拟器选MinTTY(第1项)。安装完成后,通过右键菜单或直接打开Git Bash验证安装成功。最后,配置全局用户名和邮箱,并在IDEA中设置Git路径以完成集成。
|
15天前
|
网络协议 Windows
Windows Server 各版本搭建 DNS 服务器实现域名正反向解析
Windows Server 各版本搭建 DNS 服务器实现域名正反向解析