前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >我所有在线项目的Nginx配置内容

我所有在线项目的Nginx配置内容

作者头像
老张的哲学
发布2022-04-11 11:41:34
发布2022-04-11 11:41:34
50900
代码可运行
举报
文章被收录于专栏:NetCore 从壹开始NetCore 从壹开始
运行总次数:0
代码可运行

有几个小伙伴想看看我的Nginx是怎么配置的,我这里放出来吧。

其实没太多内容,都是基本的配置:

1、域名的代理(正向/反向);

2、IP地址获取;

3、SingleR Header配置;

4、前后端配置;

5、域名配置;

6、HTTPS配置;

7、负载配置;

代码语言:javascript
代码运行次数: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;
  server_names_hash_bucket_size 64; 

    #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  600;
    proxy_read_timeout 600; 
    proxy_send_timeout 600; 

    #gzip  on;
  upstream mysvr { 
      server 192.168.10.121:3333;
      server 192.168.10.122:3333;
    }
   server {
        ....
        location  ~*^.+$ {         
           proxy_pass  http://mysvr;  #请求转向mysvr 定义的服务器列表         
        }
   }
######################################################################

    server {
        listen       80;
        server_name  www.neters.club;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
              root   C:\code\Code\Neters\home;
              index  index.html index.htm;
        }
    }


    server {
        listen       80;
        server_name  neters.club;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
              root   C:\code\Code\Neters\home;
              index  index.html index.htm;
        }
    }

    server {
        listen       80;
        server_name  ids.neters.club;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
              root   html;
              proxy_pass   http://localhost:5004;
              index  index.html index.htm;
        }

    }
  server {
        listen         443 ssl;
        server_name  ids.neters.club;  #网站域名,和80端口保持一致
        ssl             on;
        ssl_certificate 1_ids.neters.club_bundle.crt;       #证书公钥
        ssl_certificate_key  2_ids.neters.club.key;  #证书私钥

        #ssl_certificate ids.neters.club.crt;  
        #ssl_certificate_key ids.neters.club.rsa; 
 
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
        ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL;
        ssl_prefer_server_ciphers  on;
        location / {
            proxy_pass http://ids.neters.club;
            proxy_redirect  off;     
            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_set_header   Cookie $http_cookie;
            #proxy_cookie_path
            chunked_transfer_encoding       off;         
        }

    }
    server {
        listen       80;
        server_name  apk.neters.club;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        location / {
          root   html;
          proxy_pass   http://localhost:8081;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection keep-alive;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_cache_bypass $http_upgrade;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          index  index.html index.htm;
        }

        location /.doc/ {
          proxy_pass http://docs.neters.club/;
        }
    }

    server {
        listen       80;
        server_name  docs.neters.club;

        location / {
            root   C:\code\Code\Blog.Core\.docs\contents\.vuepress\dist;
            index  index.html index.htm;
        }
    }

    server {
        listen       80;
        server_name  vueadmin.neters.club;

        location / {
            try_files $uri $uri/ /index.html;
            root   C:\code\Code\Blog.Admin\distis;
            index  index.html index.htm;
        }

        location /api/ {
              rewrite  ^.+apb/?(.*)$ /$1 break;
              include  uwsgi_params;
              proxy_pass http://localhost:8081;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              #proxy_set_header Connection "upgrade";
              #proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }
        location /api2/ {
              rewrite  ^.+apb/?(.*)$ /$1 break;
              include  uwsgi_params;
              proxy_pass http://localhost:8081;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /.doc/ {
          proxy_pass http://docsadmin.neters.club/;
        }


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

    server {
        listen       80;
        server_name  docsadmin.neters.club;

        location / {
            root   C:\code\Code\Blog.Admin\.doc\contents\.vuepress\dist;
            index  index.html index.htm;
        }
    }

    

    server {
        listen       80;
        server_name  ddd.neters.club;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
              root   html;
              proxy_pass   http://localhost:4773;
              index  index.html index.htm;
        }
    }

  


    server {
        listen       80;
        server_name  vueblog.neters.club;

        location / {
            try_files $uri $uri/ /index.html;
            root   C:\code\Code\Blog.Vue\dist;
            index  index.html index.htm;
        }


        location /api {
            rewrite  ^.+apb/?(.*)$ /$1 break;
            include  uwsgi_params;
            proxy_pass   http://localhost:8081; 
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }


        location /images { 
            include  uwsgi_params;
            proxy_pass   http://localhost:8081; 
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

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


    server {
        listen       80;
        server_name  tibug.neters.club;
        
        location / {
            try_files $uri $uri/ /index.html;
            root   C:\code\Code\Nuxt.tBug\dist;
            index  index.html index.htm;
        }


        location /api {
            rewrite  ^.+apb/?(.*)$ /$1 break;
            include  uwsgi_params;
            proxy_pass   http://localhost:8081; 
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }


        location /images { 
            include  uwsgi_params;
            proxy_pass   http://localhost:8081; 
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        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;
        }
    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-01-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 NetCore 从壹开始 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档