问题描述
公司内建了业务服务器,对外提供web服务(IP+PORT),但是需要对接微信公众号,目前微信公共号只支持80,而内网众所周知的原因无法对外提供该端口。那么如何能完成业务验证和对接呢。
问题分析
1、企业进行域名备案,再更改业务端口,即可解决
2、使用Nginx反向代理实现业务代理。(本教程主要讲讲这种方法)
解决方法
1、打开nginx的配置文件nginx.conf,并进行编辑。
worker_processes auto;
error_log logs/error.log;
events {
worker_connections 1024;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 80;
server_name wx.77bx.com;
access_log /logs/access/wx.77bx.com.log;
error_log /logs/error/wx.77bx.com.log;
location / {
index index.html;
proxy_pass http://web.77bx.com:88;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-proto https;
}
}
server
{
listen 443;
server_name wx.77bx.com;
access_log /logs/access/wx.77bx.com.log;
error_log /logs/error/wx.77bx.com.log;
ssl on;
ssl_certificate /cert/wx.77bx.com/server.crt;
ssl_certificate_key /cert/wx.77bx.com/server.key;
location / {
index index.html;
proxy_pass http://web.77bx.com:88;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-proto https;
}
}
}
这样就简单实现了反向代理,如果有复杂的业务还需要具体配置。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)