美文网首页
Nginx 反向代理配置 (二)

Nginx 反向代理配置 (二)

作者: Rinaloving | 来源:发表于2022-01-13 14:20 被阅读0次

#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;

   map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
   }
 
    #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;

       upstream WebServer {
        #ip_hash;
                server 172.18.0.1:8021;
        }


    server {
        listen       80;
        server_name localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
       # proxy_pass http://172.18.0.1:8021;
     # proxy_set_header Host $http_host;
     # proxy_set_header X-Real-IP $remote_addr;
     # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     # proxy_http_version  1.1;
     # proxy_set_header Upgrade $http_upgrade;
     # proxy_set_header Connection "upgrade";
  
        }

              location /api {
                 proxy_pass http://WebServer;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Remote-Addr $remote_addr;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /ws {
      proxy_pass http://172.18.0.1:8021/ws/;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_http_version  1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
             

   

        #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

    nginx的配置、虚拟主机、负载均衡和反向代理一nginx的配置、虚拟主机、负载均衡和反向代理二nginx的配置、...

  • Nginx应用场景

    反向代理,负载均衡,动静分离 1.反向代理 修改nginx配置,并重新加载 重新加载nginx配置./nginx ...

  • 01-nginx前端方向代理

    前端反向代理 1.下载nginx 2. 配置nginx.conf反向代理

  • nginx反向代理

    什么是反向代理 如何实现反向代理 准备工作以及安装nginx 配置nginx nginx的初始配置文件去掉注释后的...

  • Nginx反向代理和负载均衡相关文章

    聊聊Nginx的反向代理 Nginx(一)-简介与安装 Nginx(二)-nginx.conf 配置文件 Ngin...

  • nginx 配置

    nginx 多个 root页面配置 反向代理

  • 第二课 nginx+tomcat集群

    正向代理,反向代理 配置Nginx 配置文件目录:/usr/local/nginx-1.6.1/conf/ngin...

  • nginx+tomcat集群

    正向代理,反向代理 配置Nginx 配置文件目录:/usr/local/nginx-1.6.1/conf/ngin...

  • nginx+tomcat集群

    正向代理,反向代理 配置Nginx 配置文件目录:/usr/local/nginx-1.6.1/conf/ngin...

  • NGINX配置https

    一安装nginx yum installnginx.x86_64 二配置 nginx conf 1.反向代理+负载...

网友评论

      本文标题:Nginx 反向代理配置 (二)

      本文链接:https://www.haomeiwen.com/subject/rolbyltx.html