Windows 利用 Nginx 转发22端口
Mr.Lee 2024-05-21 14:56:20 WindowsNginx
最近要出差, 需要在现场连接到天津的服务器做开发. 现在就需要一个VPN工具.....可恶的是, VPN工具没有Arm版本...只能跟公司申请一台x86的电脑. 但是问题来了....开发环境要重新搞, 操作习惯也需要重新适应...想想算了....带两台电脑吧
用x86的电脑, 做22的端口转发, 用自己的Mac做开发.
接下来, 是我在Windows下的一些操作
# 配置Nginx转发
stream {
# 写法一
upstream ssh_backend {
server 10.13.144.5:22
}
server {
listen 22;
proxy_pass ssh_backend;
}
# 写法二
# server {
# listen 22;
# proxy_connect_timeout 1s;
# proxy_timeout 3s;
# proxy_pass 10.13.144.5:22;
# }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 配置 Nginx 自启动
下载WinSW.NET4.exe,放至待包装的exe文件夹中,这里就是nginx.exe所在的目录,并修改名字为“nginxservice.exe”
在nginxservice.exe同目录中新建一个同名的xml文件
<!--
MIT License
Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees,
Inc., Oleg Nenashev and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<!--
This is an example of a minimal Windows Service Wrapper configuration, which includes only mandatory options.
This configuration file should be placed near the WinSW executable, the name should be the same.
E.g. for myapp.exe the configuration file name should be myapp.xml
You can find more information about the configuration options here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
Full example: https://github.com/kohsuke/winsw/blob/master/examples/sample-allOptions.xml
-->
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>Nginx</id>
<!-- Display name of the service -->
<name>NginxService</name>
<!-- Service description -->
<description>Nginx 服务</description>
<!-- Path to the executable, which should be started -->
<executable>C:\software\nginx\nginx.exe</executable>
</service>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
执行
nginxservice.exe install
记得配置电源策略, 带电源情况下和上盖子, 电脑继续工作.... 然后就都可以了.....成功的将背包增重了2kg 🥺🥺🥺
参考文章:
- https://www.cnblogs.com/merray/p/8460992.html
- https://github.com/winsw/winsw/releases