`

nginx 配置

 
阅读更多

#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" '
    #                  '$stIatus $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;

   upstream mysvr {
    server 主机:8080  weight=1;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location ^~/mmo{
            root   html;
            index  index.html index.htm;
            proxy_pass  http://mysvr ;#请求转向mysvr 定义的服务器列表

          #以下是一些反向代理的配置可删除.

          proxy_redirect off;

          #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
          proxy_set_header Host $host:$server_port;
          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;  #nginx跟后端服务器连接超时时间(代理连接超时)
          proxy_send_timeout 90;        #后端服务器数据回传时间(代理发送超时)
          proxy_read_timeout 90;         #连接成功后,后端服务器响应时间(代理接收超时)
          proxy_buffer_size 4k;             #设置代理服务器(nginx)保存用户头信息的缓冲区大小
          proxy_buffers 4 32k;               #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置
          proxy_busy_buffers_size 64k;    #高负荷下缓冲大小(proxy_buffers*2)
          proxy_temp_file_write_size 64k;  #设定缓存文件夹大小,大于这个值,将从upstream服务器传
        }

        #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配置https详细步骤,从安装OpenSSL和Nginx,到生成证书,nginx配置(包括配置http请求转发到https)等

    **步骤1:** 在 Nginx 配置目录 (`D:\nginx\conf`) 打开命令行窗口。 **步骤2:** 生成私钥。运行命令 `openssl genrsa -des3 -out server.key` 并设置密码。 **步骤3:** 创建 CSR 文件。执行 `openssl req -new -...

    Nginx 配置文件 nginx.conf 详解

    Nginx 配置文件 nginx.conf 详解 Nginx 配置文件 nginx.conf 是 Nginx 服务器的核心配置文件,它控制着 Nginx 服务器的行为和性能。在这个配置文件中,我们可以设置服务器的用户和组、工作进程数、错误日志、进程...

    nginx配置多个静态资源.docx

    nginx配置多个静态资源 本文将详细介绍nginx配置多个静态资源的知识点,从基本概念到配置实践,涵盖了nginx配置文件的各个组件和指令。 nginx配置文件结构 nginx配置文件主要由以下几个部分组成: * main块:...

    Nginx配置文件(nginx.conf)配置详解[定义].pdf

    Nginx配置文件(nginx.conf)配置详解 Nginx配置文件(nginx.conf)是Nginx服务器的核心配置文件,用于定义Nginx服务器的行为和配置。下面是Nginx配置文件的详细配置解释: 用户和组 Nginx配置文件中指定了用户和组,...

    项目打包运行dist以及nginx配置

    在IT行业中,项目打包运行和Nginx配置是两个关键环节,它们对于应用程序的部署和发布至关重要。这里我们将深入探讨这两个主题。 首先,项目打包运行通常指的是将开发完成的前端或后端应用转换为可部署的形式。对于...

    notepad++编辑nginx配置文件支持高亮

    在标题“notepad++编辑nginx配置文件支持高亮”中,我们关注的是如何在Notepad++中实现对Nginx配置文件的语法高亮显示,这将极大提升开发者的阅读和编写效率。 Nginx是一款高性能的HTTP和反向代理服务器,其配置...

    windows下 php+nginx配置详解

    设置监听地址和端口,与Nginx配置中的`fastcgi_pass`对应: ```ini listen = 127.0.0.1:9000 ``` 启动Nginx和PHP-FPM服务。如果一切配置无误,现在你应该可以通过浏览器访问`http://localhost/`并看到Nginz的欢迎...

    nginx配置 +负载均衡+https协议

    - 对于负载均衡,可以通过在Nginx配置文件中定义多个后端服务器,并使用`proxy_pass`指令来实现。 ```nginx upstream backend { server backend1.example.com; server backend2.example.com; } server { ...

    Windows平台,Nginx配置文件修改自动加载重启

    本教程将介绍一种方法,使得在Windows环境下,Nginx配置文件修改后能够自动加载并重启,以实现配置的即时生效。 首先,`nginx.conf`是Nginx的主要配置文件,它包含了服务器的各项设置,如监听端口、服务器块、反向...

    Nginx配置SSL自签名证书的方法

    3. **编辑Nginx配置文件**:找到Nginx的配置文件,通常是`/etc/nginx/nginx.conf`或`/usr/local/nginx/conf/nginx.conf`。添加一个新的`server`块,配置如下: ```nginx server { listen 80; listen 443 ssl; # ...

    微信小程序https服务nginx配置示例.pdf

    6. 反向代理配置:在nginx配置中,proxy_pass指令用于指定后端的服务器地址,这里指向了本地的8080端口。同时,还通过proxy_set_header指令设置了传递给后端服务器的HTTP头信息,如X-Forwarded-For(客户端IP地址)...

    windows下nginx配置https以及同一个端口监听多个网站即监听多个虚拟主机

    在Windows环境下,配置Nginx以支持HTTPS及在同一端口监听多个网站,即配置多个虚拟主机,是一项常见的网络服务设置任务。...同时,根据实际需求,还可以对Nginx配置进行更复杂的优化,如负载均衡、缓存等。

    Nginx 配置说明文档

    Nginx 配置说明文档 Nginx 配置说明文档是指 Nginx 服务器的配置文件,用于管理和配置 Nginx 服务器的各种设置。这个文档对 Nginx 的配置进行了详细的说明,涵盖了 Nginx 的基本配置、进程管理、错误日志、事件处理...

    Vue项目部署Nginx配置文件 SSL

    在部署 Vue 项目时,Nginx 配置文件 `nginx.conf` 的关键设置如下: 1. **基本配置**: - `server` 块:定义一个监听特定端口(通常是80)的服务器实例。 ```nginx server { listen 80; server_name your...

    Nginx配置http转https以及https访问http静态资源.docx

    三、Nginx配置安全头 在上面的配置文件中,我们使用了add_header指令来添加Content-Security-Policy头,以便升级不安全的请求。这可以防止攻击者inject恶意脚本来攻击网站。 四、Nginx配置错误页面 在上面的配置...

    Nginx配置如何区分PC或手机访问不同域名

    在Nginx配置中,我们通常使用`if`语句和`rewrite`模块来根据不同的条件重写请求。例如,若想在移动端访问时重定向到另一个域名(如***),可以利用Nginx配置文件中的`if`语句,结合正则表达式匹配HTTP_USER_AGENT,...

    Windows下Nginx配置SSL实现Https访问(包含证书生成)

    此时,`ssl` 文件夹中将包含 `lee.crt` 和 `lee.key` 两个文件,这两个文件是接下来配置 Nginx 所需的。 ##### 5. 修改 Nginx 配置文件 - 打开 `C:\wnmp\nginx\conf\nginx.conf` 文件。 - 修改以下代码: ```...

    nginx配置.zip

    1. **Nginx配置基础** Nginx的配置文件通常位于`/etc/nginx/`目录下,其中`nginx.conf`是主配置文件,它包含了整个Nginx服务器的基本设置。`conf.d`目录则用于存放多个独立的配置片段,这种方式使得配置管理更加...

    squid和nginx配置正向代理访问API接口.rar

    总结一下,"squid和nginx配置正向代理访问API接口"涉及的关键知识点包括正向代理的概念、Squid和Nginx的代理功能、配置这两者的步骤、以及安全性控制和优化策略。正确配置和使用这两个工具可以帮助企业构建高效、...

    Nginx配置文件——一级域名、二级域名

    本文将深入探讨如何通过Nginx配置文件来设置一级域名和二级域名,以及如何利用Nginx的反向代理功能。 首先,了解一级域名和二级域名的概念至关重要。一级域名是互联网上顶级的域名,如.com、.org、.net等。二级域名...

Global site tag (gtag.js) - Google Analytics