{"id":266,"date":"2022-03-14T20:59:51","date_gmt":"2022-03-14T12:59:51","guid":{"rendered":"http:\/\/feel.name\/?p=266"},"modified":"2022-03-14T21:01:46","modified_gmt":"2022-03-14T13:01:46","slug":"nginx-stream%e6%a8%a1%e5%9d%97%e6%9d%a5%e7%ab%af%e5%8f%a3%e8%bd%ac%e5%8f%91","status":"publish","type":"post","link":"http:\/\/feel.name\/?p=266","title":{"rendered":"Nginx stream\u6a21\u5757\u6765\u7aef\u53e3\u8f6c\u53d1"},"content":{"rendered":"\n<p>wget https:\/\/nginx.org\/download\/nginx-1.18.0.tar.gz<br>ls<br>tar -zxvf nginx-1.18.0.tar.gz<br>yum -y install gcc gcc-c++ autoconf automake<br>yum -y install zlib zlib-devel openssl openssl-devel pcre-devel<br>cd nginx-1.18.0<br>.\/configure &#8211;prefix=\/opt\/nginx &#8211;sbin-path=\/opt\/nginx\/sbin\/nginx &#8211;conf-path=\/opt\/nginx\/conf\/nginx.conf &#8211;with-http_stub_status_module &#8211;with-http_gzip_static_module &#8211;with-stream<br>make<br>make install<br>cd \/opt\/<br>ls<br>cd nginx\/<br>cd conf\/<br>vi nginx.conf<br>\u6dfb\u52a0\u672c\u573010091\u7aef\u53e3\u8f6c\u53d1ip\u548c\u7aef\u53e3192.168.0.91:2222<\/p>\n\n\n\n<p>stream {<br>server {<br>listen 10091;<br>proxy_connect_timeout 600s;<br>proxy_timeout 3s;<br>proxy_pass 192.168.0.91:2222;<br>proxy_socket_keepalive on;<br>}<br>}<\/p>\n\n\n\n<p>cd ..<br>cd sbin\/<br>.\/nginx -t<br>.\/nginx<br>netstat -tnlp<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u3000\u3000ps -ef | grep nginx<\/p>\n\n\n\n<p>\u3000\u3000\u4ece\u5bb9\u505c\u6b62 &nbsp; kill -QUIT \u4e3b\u8fdb\u7a0b\u53f7<\/p>\n\n\n\n<p>\u3000\u3000\u5feb\u901f\u505c\u6b62 &nbsp; kill -TERM \u4e3b\u8fdb\u7a0b\u53f7<\/p>\n\n\n\n<p>\u3000\u3000\u5f3a\u5236\u505c\u6b62 &nbsp; kill -9 nginx<\/p>\n\n\n\n<p>\u6309\u4e0a\u9762\u6765\u6d4b\u8bd5\u540e\u53d1\u73b0ssh\u8fc7\u4e0d\u53bb<\/p>\n\n\n\n<p>[root@Test1 ~]# ssh -p 10091 root@192.168.0.66<br>root@192.168.0.66&#8217;s password:<br>Authentication failed.<\/p>\n\n\n\n<p>\u8f93\u5165\u5bc6\u7801\u540e\u8ba4\u8bc1\u5931\u8d25\uff0c\u67e5\u770b\u65e5\u5fd7<\/p>\n\n\n\n<p>Mar 14 08:30:37 TEST2 sshd[1220]: Connection closed by 192.168.0.66 port 52548 [preauth]<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5176\u5b9estream\u6a21\u5757\u6309\u6807\u51c6\u5199\u5c31\u597d\u4e86<\/p>\n\n\n\n<p>stream {<br>upstream ssh {<\/p>\n\n\n\n<pre class=\"wp-block-code has-normal-font-size\"><code>    hash $remote_addr consistent;\n    server 192.168.0.91:2222;\n}\n server {\n    listen 10091;\n    proxy_connect_timeout 60s; \n    proxy_timeout 60s;\n    proxy_pass ssh;\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>Mar 14 08:44:38 TEST2 sshd[1232]: Connection closed by 192.168.0.66 port 52552 [preauth]<br>Mar 14 08:44:56 TEST2 sshd[1234]: Bad protocol version identification &#8216;GET \/ HTTP\/1.1&#8217; from 192.168.0.66 port 52554<br>Mar 14 08:55:21 TEST2 sshd[1236]: Bad protocol version identification &#8216;GET \/ HTTP\/1.1&#8217; from 192.168.0.66 port 52556<br>Mar 14 08:55:29 TEST2 sshd[1237]: Accepted password for root from 192.168.0.66 port 52558 ssh2<br>Mar 14 08:55:29 TEST2 sshd[1237]: pam_unix(sshd:session): session opened for user root by (uid=0)<br>Mar 14 08:55:31 TEST2 sshd[1237]: Received disconnect from 192.168.0.66 port 52558:11: disconnected by user<br>Mar 14 08:55:31 TEST2 sshd[1237]: Disconnected from 192.168.0.66 port 52558<br>Mar 14 08:55:31 TEST2 sshd[1237]: pam_unix(sshd:session): session closed for user root<\/p>\n","protected":false},"excerpt":{"rendered":"<p>wget https:\/\/nginx.org\/download\/nginx-1.18.0.tar.gzlsta&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":4,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":270,"href":"http:\/\/feel.name\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/270"}],"wp:attachment":[{"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/feel.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}