nginx 做域名解析转发nodejs/tomcat/jar服务等端口

转发nodejs 映射端口

server {
    listen 8005;
    server_name localhost;
    location /{
            proxy_set_header X_Real_IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:3000;
        proxy_redirect off;
    }
}


 server {
listen 80;
server_name admin.todayefinance.com;


location ^~ / {
proxy_pass http://127.0.0.1:10000/;
}
}

 

 

 转发tomcat 下静态文件 

server {
listen 80;
server_name todayefinance.com www.todayefinance.com;


server_name_in_redirect off;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location / {
proxy_pass http://127.0.0.1:8077;
}
}

 

 转发spring boot(jar) 服务

    server {
        listen      80;
        server_name m.todayefinance.com;
    #此为springboot 服务    
    location /psq/{
                 proxy_redirect off;
                proxy_set_header Host $host;
               proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_pass http://127.0.0.1:10087/;
       }
    #location ^~ / {
    #            proxy_pass http://127.0.0.1:10001/;
    #    }
    #client_max_body_size 75M;
    
    location / {    
                proxy_pass http://127.0.0.1:8018;
        }
    

    } 

 

转发 各种服务

#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;
    gzip_min_length  5k;
    gzip_buffers     4 16k;
    #gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types       text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;

    server {
        listen       80;
        server_name  tms.kjfraud.com;

    location ^~ /pics/ {
              gridfs ivs
              field=filename
              type=string;
              mongo 127.0.0.1:27017;
        }
    
    location / {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:10011/;
    }
    
    location /ivs-tms/ {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8080/ivs-tms/;
        }
    }

    server {
        listen       80;
        server_name  admin.kjfraud.com;
    location ^~ /pics/ {
              gridfs ivs
              field=filename
              type=string;
              mongo 127.0.0.1:27017;
        }

    location / {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:10010/;
    }
    
    location /ivs-admin/ {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8080/ivs-admin/;
        }
    }

    server {
        listen       80;
        server_name  www.kjfraud.com;

    location ^~ /test/ {
              gridfs test
              field=filename
              type=string;
              mongo 127.0.0.1:27017; 
    }

    location ^~ /pics/ {
              gridfs ivs
              field=filename
              type=string;
              mongo 127.0.0.1:27017;
        }
    location /admin {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://admin.beefba.com;
    }

    location /tms/ {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://tms.beefba.com;
        }
    
    location /ivs-admin {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8080/ivs-admin;
        }

    location /ivs-tms {
            proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8080/ivs-tms;
        }


    # 官网预留
        location / {
               proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
        }
    
    error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

   server {
        listen       80;
        server_name  erp.kjfraud.com;
        location ^~ / {
              proxy_pass http://127.0.0.1:10030;
        }
}
    server {
    listen 443;
        server_name kjfraud.com;
        ssl on;
        root html;
        index index.html index.htm;
        ssl_certificate   cert/214276277410066.pem;
        ssl_certificate_key  cert/214276277410066.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;

         location ^~ /ivs-admin {
                        proxy_redirect off;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_pass http://127.0.0.1:8080/ivs-admin;
        }

    location ^~ /ivs-tms {
                        proxy_redirect off;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_pass http://127.0.0.1:8080/ivs-tms;
        }

    location ^~ /ivs-core {
                        proxy_redirect off;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_pass http://127.0.0.1:8080/ivs-core/core;
        }

    location / {
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8080/ivs-tms/login;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

}

 

posted @ 2020-02-18 20:33  这很周锐  阅读(662)  评论(0编辑  收藏  举报