nginx配置实例

#user nobody;
worker_processes auto;

error_log logs/error.log;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

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

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

include gzip.conf;

server {
    listen       8081;
    server_name  localhost;

    location / {
        root /opt/nginx1/html/st;
        index  index.html;
        try_files $uri $uri/ index.html;
    }

    location ^~ /mete/ {
        proxy_pass http://223.105.0.225:18081/;
        proxy_set_header host $host;
        proxy_set_header clientIP $remote_addr;
        proxy_set_header forwarded-for $proxy_add_x_forwarded_for;
        #include proxy.conf;
    }

    location ^~ /geom {
        proxy_pass http://223.105.5.58:18086/;
        include proxy.conf;
    }
    location ^~ /angle {
        proxy_pass http://223.105.5.61:18087/;
        include proxy.conf;
    }
    location ^~ /smoke/ {
        proxy_pass http://223.105.2.157:18001/;
        proxy_set_header host $host;
        proxy_set_header clientIP $remote_addr;
        proxy_set_header forwarded-for $proxy_add_x_forwarded_for;
        #proxy_set_header Host $host;a
        #include proxy.conf;
    }
    location ^~ /mgmt/ {
        proxy_pass https://223.105.2.158:13000/;
        proxy_set_header host $host;
        proxy_set_header clientIP $remote_addr;
        proxy_set_header forwarded-for $proxy_add_x_forwarded_for;
        #include proxy.conf;
    }
}

}