nginx代理tcp协议_tcp怎么加密传输

nginx代理tcp协议_tcp怎么加密传输NGINX实现TCP加密代理

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

实现转发MySql、Redis、矿池ssl 以及各种TCP转发

NGINX实现TCP代理

源码安装NGINX

NGINX官网源码包:NGINX官网下载地址

wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar -zxf nginx-1.20.1.tar.gz
yum install -y pcre-devel pcre zlib zlib-devel openssl openssl-devel wget gcc gcc-c++ unzip
useradd -s /sbin/nologin nginx
tar -xvf nginx-1.20.1.tar.gz
cd nginx-1.20.1/
sed -i '49s/nginx/Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
sed -i '50s/: /: Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
sed -i '51s/: /: Microsoft-IIS/' src/http/ngx_http_header_filter_module.c
./configure \
--prefix=/opt/nginx/ \
--user=nginx \
--group=nginx \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module 
make && make install
ln -s /opt/nginx/sbin/nginx  /usr/bin/nginx
nginx
ps -aux|grep nginx

修改配置文件

vim /opt/nginx/conf/nginx.conf

worker_processes  auto;
error_log		logs/error.log error;
pid		logs/nginx.pid;
events { 
   	
	worker_connections  65535;
	multi_accept on;
}

stream{ 
   
   #Ethermine
    upstream ethermine{ 
   
    server asia1.ethermine.org:5555; #这以E池为走ssl
  }

  server { 
   
    listen 5555 ssl;
    proxy_connect_timeout 10s;
    proxy_timeout 30s;
    proxy_ssl  on;
    proxy_ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
    proxy_ssl_session_reuse on;
    
    ssl_certificate      baidu.com.crt;    #自己的域名证书
    ssl_certificate_key  baidu.com.key;
    proxy_pass ethermine;
  }   
}



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;
	keepalive_timeout  60;
	add_header Access-Control-Allow-Origin '*';
        add_header Access-Control-Max-Age '3628800';
	add_header Access-Control-Allow-Credentials 'true';
	add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
	add_header Access-Control-Allow-Methods 'GET,POST,PUT,OPTIONS';

	underscores_in_headers on;	

	client_header_buffer_size	32k;
	client_body_buffer_size	20m;
	client_max_body_size	120M;
	client_header_timeout	1m;
	client_body_timeout		1m;
	proxy_connect_timeout    600;
	proxy_read_timeout       600;
	proxy_send_timeout       600;
	large_client_header_buffers	4	32k;
	fastcgi_buffers		4	128k;
	fastcgi_buffer_size		128k;
	fastcgi_busy_buffers_size	256k;

	server_tokens off;
	tcp_nopush on;
	tcp_nodelay on;
	sendfile        on;

	gzip  on; #开启gzip
	#gzip_static on;
	gzip_vary on;
	gzip_min_length 1k;
	gzip_buffers 8 32k;
	gzip_http_version 1.1;
	gzip_comp_level 6; 
	gzip_proxied any;
	gzip_types application/javascript application/json text/css image/png;

	real_ip_header		X-Real-IP;
	proxy_set_header        Host            $host:$server_port;
	proxy_set_header        X-Real-IP       $remote_addr;
	proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;   

	include      /opt/nginx/conf.d/*.conf; } 

重启NGINX

nginx -t 
nginx -s reload
netstat -nutlp 

测试

iptables 记得开启端口

telnet  xxx.com 端口
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/195524.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Linux文件编辑命令详细整理

    Linux文件编辑命令详细整理

    2020年11月12日
    223
  • leetcode链表问题_c++反转链表

    leetcode链表问题_c++反转链表给你单链表的头指针 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表 。示例 1:输入:head = [1,2,3,4,5], left = 2, right = 4输出:[1,4,3,2,5]示例 2:输入:head = [5], left = 1, right = 1输出:[5] 提示:链表中节点数目为 n1 <= n <= 500-500

    2022年8月8日
    5
  • QT中this指针

    QT中this指针一:this指针只能在一个类的成员函数中调用,它表示当前对象的地址。下面是一个例子: void Date::setMonth( int mn) { month=mn; // 这三句是等价的 this->month=mn; (*this).month=mn; }1.this只能在成员函数中使用。全局函数,静态函数都不能使用th

    2022年5月17日
    144
  • netperf 而网络性能测量

    netperf 而网络性能测量

    2022年1月15日
    52
  • Python保留小数又不想四舍五入咋办?

    Python保留小数又不想四舍五入咋办?保留小数又不想四舍五入咋办?找了一会不知道用什么函数实现,突然想到可以这样…a=25.35568a=a-a%0.01print(a)

    2022年8月11日
    8
  • odrive入门教程(securecrt使用教程串口)

    ODrive官方入门指南中,采用的是USB连接控制模式(中文翻译版本链接)使用的是NativeProtocol。当我们需要尝试串口通信实现时,需要专程ASCII协议来进行串口通信实现相关的命令,结合着入门指南以及ODrive中的相关属性方法参数,将流程中用到的相关方法整理如下:importserialimporttimeted=serial.Serial(port=’/dev/tty.wchusbserial1470′,baudrate=115200)ted.writ

    2022年4月16日
    53

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号