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" '
    #                  '$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;
    #生效-1
    root C://Users/dhht/Desktop/nginx-1.22.0/jdy/;

    server {
        listen 8000;
        server_name localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location / {
            #生效-2
            #root   html;
            #生效-3
            #root C://Users/dhht/Desktop/nginx-1.22.0/jdy/;
            try_files $uri $uri/ /index.html;
        }

        location /api/ {
            #proxy_pass http://10.0.0.27:6001/;
			proxy_pass http://127.0.0.1:8088/;
            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_set_header HTTP_X_FORWARDED_FOR $remote_addr;
            proxy_redirect default;
            proxy_read_timeout 3600s;
            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;
    #    }
    #}
    #添加门户,可用
    server {
        listen 8001;
        server_name hnyzxt.hnga.gov.cn;
        #access_log /var/log/nginx/host.access.log main;
        client_header_buffer_size 128k;
        client_body_buffer_size 1m;

        location /portal {
            proxy_pass http://127.0.0.1:8080/portal/;
            proxy_set_header Host $host:8001;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
            #client_header_buffer_size 128k;
            #client_body_buffer_size 1m;
            proxy_buffering on;
            proxy_max_temp_file_size 1024m;
            #proxy_redirect default;
            proxy_redirect off;
            client_max_body_size 50m;
            proxy_connect_timeout 3000;
            proxy_send_timeout 3000;
            proxy_read_timeout 3000;

        }

        #加载门户静态资源
        location /static {
            proxy_pass http://127.0.0.1:8080/portal/static;
            proxy_set_header Host $host:8001;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
            #client_header_buffer_size 128k;
            #client_body_buffer_size 1m;
            proxy_buffering on;
            proxy_max_temp_file_size 1024m;
            #proxy_redirect default;
            proxy_redirect off;
        }
    }

}

posted @ 2023-03-08 17:17  qing222  阅读(17)  评论(0编辑  收藏  举报