# Nginx代理OA仅移动端访问

# 解决方案

nginx.conf配置:

worker_processes auto;
worker_rlimit_nofile 20960;
error_log  logs/error.log  error;
events {
	worker_connections  4096;
	multi_accept on;
	accept_mutex on;
	accept_mutex_delay 500ms;
}
http {
        server_tokens off;
        sendfile on;
        tcp_nopush on; 
        tcp_nodelay on;
        access_log off;
        include       mime.types;
        default_type  application/octet-stream;
        keepalive_timeout  300;
        client_max_body_size 10240M;
        # 开启gzip
        gzip on;
        # 1KB以下不进行gzip
        gzip_min_length 1k;
        # 设置gzip的buffer
        gzip_buffers 4 16k;
        # 设置gzip的等级,等级越高压缩比例越大,越消耗cpu
        gzip_comp_level 3;
        # 设置gzip的压缩类型
        gzip_types text/xml text/plain text/css text/javascript application/x-javascript application/javascript application/xml application/json;
        # ie6及以下版本浏览器不进行gzip
        gzip_disable "MSIE [1-6]\.";
        # 定义一个upstream,名称(seeyon_v5_cluster,可更改)、模式(必须为sticky)及其服务集(server,192.168.0.1为服务ip,80为http端口,以实际情况进行修改)
        upstream seeyon_v5_cluster{
                sticky;
				server 172.20.2.20:80 max_fails=300 fail_timeout=30s;
			    #server 10.3.4.108:80 max_fails=300 fail_timeout=30s;
        }
          # 定义一个server
          server {
          # 设置监听端口
          listen 80;
          # 设置 server 名称
          server_name localhost;
          # 设置字符集
          charset utf-8;
          ##aio threads;
          ##aio_write on;
          # 设置 location
          include part.conf;
                   error_page   500 502 503 504  /50x.html;
                   location = /50x.html {
                   root   html;
                 }
                }
                # https配置
      }

part.conf配置(与nginx.conf放置同一目录):

location ~ /seeyon/webOfficeTolen.do {
        proxy_pass http://seeyon_v5_cluster;
        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_redirect     off;
        proxy_connect_timeout 300;
        proxy_read_timeout 300;
        proxy_send_timeout 300;
}

location ~ /seeyon/m3/apps/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/m3/cmp/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/rest/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/apps_res/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /mobile_portal/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/isignaturehtmlH5servlet {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /wechat/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/fontimage/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/common/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/portal/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/H5/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/office/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /favicon.ico {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/commonimage.do {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/skin/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/verifyCodeImage.jpg {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/officeTrans.do {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/getAjaxDataServlet {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /static/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}


location ~ ^/seeyon/.*\.js$ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}


location ~ /seeyon/main/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/wechat/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}

location ~ /seeyon/collaboration/ {
	proxy_pass http://seeyon_v5_cluster;
	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_redirect     off;
	proxy_connect_timeout 300;
	proxy_read_timeout 300;
	proxy_send_timeout 300;
}
编撰人:zhangshuang、wangyxyf、qiaoyulong