nginx配置代理转发

為{幸葍}努か 提交于 2020-01-14 10:16:31
  1. 由于公司给部门分配的端口数量有限,外网使用较为麻烦,因此采用代理服务进行转发。
  2. 要求每个项目必须拥有合适的项目名称,如:http//:www.xxx.com/项目名,且这些服务站点都不可被外网访问,统一进行代理服务配置。
  3. 对于有上传大文件需求,client_max_body_size 上传设置文件大小。

#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;
    client_max_body_size 500M;
	
    server {
        listen       8111;
        server_name  service.xxxx.cn;
		port_in_redirect on;
		proxy_set_header Host $host:8111;  
		proxy_set_header X-Forwarded-For $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        location  /jfpt {
           proxy_pass http://localhost:3110/jfpt;
        }
		
		location /core {
			proxy_redirect off;
			proxy_pass http://localhost:1981/core;
		}
		location /fams {
			proxy_redirect off;
			proxy_pass http://localhost:1981/fams;
		}
    }

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!