nginx配置示例

例1:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

worker_rlimit_nofile 65535;#//配置连接数,与服务器有关
events {
    worker_connections 4096;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

gzip on;#配置文件压缩
gzip_static on;
gzip_min_length  5k;
gzip_buffers     4 16k;
#gzip_http_version 1.0;
gzip_comp_level 3;
gzip_types       text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       8000 default_server;
        #listen       8.141.48.129:80 default_server;
        #server_name  _;
        #root         /usr/share/nginx/html;

       location /api {
          proxy_pass http://8.141.48.129:1200/;
       }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            root   /usr/local/apache-tomcat-8.5.33/webapps/dist;
            index  index.html index.htm;

                try_files $uri $uri/ /index.html;
        }

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

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#        location = /404.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#        }
#    }

}

例2:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

worker_rlimit_nofile 65535;#//配置连接数,与服务器有关
events {
    worker_connections 4096;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

gzip on;#配置文件压缩
gzip_static on;
gzip_min_length  5k;
gzip_buffers     4 16k;
#gzip_http_version 1.0;
gzip_comp_level 3;
gzip_types       text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;

       #rewrite ^/(.*)$ https://172.20.10.29:443/$1 permanent;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


       location /api {
          proxy_pass http://172.20.10.29:8888/api/v1/;
       }

    location ^~ /rest/qf {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.41:8080;
        }
    }


    location ^~ /rest/dataReport {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /rest/monitoring {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /common {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.2:9090;
        }
    }


        location / {
            root   /usr/local/milun/daping/distt;
            index  index.html index.htm;
        }

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

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


server {
        listen       9091 ;
        server_name  172.20.10.29;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        #location /api {
          #  proxy_pass http://172.20.10.29:8081/api/v1/;
       # }

    location ^~ /rest/qf {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.41:8080;
        }
    }


    location ^~ /rest/dataReport {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /rest/monitoring {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /common {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.2:9091;
        }
    }


        location / {
            root   /usr/local/milun/daping/caslogin;
            index  index.html index.htm;
        }

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

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

server {
        listen       9092 ;
        server_name  172.20.10.29;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        #location /api {
          #  proxy_pass http://172.20.10.29:8081/api/v1/;
       # }

    location ^~ /rest/qf {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.41:8080;
        }
    }


    location ^~ /rest/dataReport {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /rest/monitoring {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.43:80;
        }
    }

    location ^~ /common {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://172.20.10.2:9091;
        }
    }


        location / {
            root   /usr/local/milun/dict/dist;
            index  index.html index.htm;
        }

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

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

    server {
        listen      9093;
        server_name  172.20.10.29;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

location /ljzdweb/ {
           #此为新应用index,static目录,同时注意这里是alias,不是root,还有以及new的后面有/结尾
                alias /usr/local/milun/ljzdweb/;
                try_files $uri $uri/ /ljzdweb/index.html;
                index index.html index.htm;
        }

    location /ljzdwebApi/{
         proxy_pass http://39.164.52.76:20033/;
    }

        location / {
            root   /usr/local/milun/xiazhongrui/dist;
            index  index.html index.htm;
        }

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

stream{
  log_format basic '$remote_addr [$time_local] ' '$protocol $status $bytes_sent $bytes_received' '$session_time';

  upstream impala { #impala daemon
    least_conn; #路由策略:least_conn:最少连接
    server 172.20.10.2:21000;
    server 172.20.10.3:21000;
    server 172.20.10.4:21000;
    server 172.20.10.5:21000;
    server 172.20.10.6:21000;
    server 172.20.10.7:21000;
    server 172.20.10.8:21000;
    server 172.20.10.9:21000;
  }
  upstream impala-jdbc {
    least_conn;
    server 172.20.10.2:21050;
    server 172.20.10.3:21050;
    server 172.20.10.4:21050;
    server 172.20.10.5:21050;
    server 172.20.10.6:21050;
    server 172.20.10.7:21050;
    server 172.20.10.8:21050;
    server 172.20.10.9:21050;
  }
  server{ #impala 负载均衡
    listen 21000;
    proxy_pass impala;
  }
  server{ #impala jdbc 负载均衡
    listen 21050;
    proxy_pass impala-jdbc;
  }
}

例3:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

worker_rlimit_nofile 65535;
events {
    worker_connections 4096;
}

http {
    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  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

gzip on;
gzip_static on;
gzip_min_length  5k;
gzip_buffers     4 16k;
#gzip_http_version 1.0;
gzip_comp_level 3;
gzip_types       text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name 192.168.9.36;
        root         /usr/local/milun/ipsourcesys;
    #listen       [::]:80;
        #server_name  _;
       # root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location /api{
            proxy_pass http://192.168.9.36:8001/api;
        }
       location /apk{
            proxy_pass http://192.168.9.36:8010/apk;
        }

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

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

server {
        listen       20021 ;
        server_name  192.168.9.45;

#server_name_in_redirect on;
#关闭自动添加端口
#port_in_redirect off;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

    #通过访问时添加后缀来隐藏URL中的后缀
    #if (!-e $request_filename){
        #rewrite ^/(.*)([^/])$ http://$host:20006/$1$2/ permanent;
        #rewrite ^([^.]*[^/])$ $1/ permanent; 
       # rewrite ^/(.*)$ $1/ permanent;
        #break;
    #}

        location /api{
            proxy_pass http://192.168.9.45:8002/api;
        }
       location /apk{
            proxy_pass http://192.168.9.36:8010/apk;
        }
       

    location ^~ /rest/qf {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.45:8002;
        }
    }


    location ^~ /rest/dataReport {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.45:8002;
        }
    }

    location ^~ /rest/monitoring {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.45:8002;
        }
    }

    location ^~ /common {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.45:8002;
        }
    }


        location / {
            root   /usr/local/milun/csidebacksys;
            index  index.html index.htm;
        }

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

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

server {
        listen       20080 ;
        server_name  39.164.52.76;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        location /api/ {
            proxy_pass http://39.164.52.76:20019/;
        }
       location /apk/{
            proxy_pass http://39.164.52.76:20020/;
        }

    location ^~ /rest/qf {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.36:8002;
        }
    }


    location ^~ /rest/dataReport {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.36:8002;
        }
    }

    location ^~ /rest/monitoring {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        proxy_hide_header Access-Control-Allow-Origin;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.36:8002;
        }
    }

    location ^~ /common {
        proxy_set_header Origin '';
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Headers $http_access_control_request_headers;
        add_header Access-Control-Allow-Methods POST,GET,OPTIONS,DELETE,PUT,HEAD,PATCH;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header Access-Control-Expose-Headers $http_access_control_request_headers;

        if ($request_method = 'OPTIONS') {
            return 204;
        }
        if ($request_method != 'OPTIONS'){
            proxy_pass http://192.168.9.36:8002;
        }
    }


        location / {
            root   /usr/local/milun/waph5;
    try_files $uri $uri/ @router;
            index  index.html index.htm;
        }

location /ljzdweb {
           #此为新应用index,static目录,同时注意这里是alias,不是root,还有以及new的后面有/结尾
                alias /usr/local/milun/ljzdweb/;
                try_files $uri $uri/ /new/index.html;
                index index.html index.htm;
              
        }
        location @router {
                rewrite ^.*$ /index.html last;
}

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

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

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值