常用命令
端口号占用情况
修改本地端口和域名的对应信息(即host文件)
- 文件地址- 
内网穿透
博客
- 准备一台公网服务器
- nginx.conf添加内容
```nginx
用nginx创建代理,如果有人访问http://x.xx.xxx
nginx会把请求转发给tunnel,这个tunnel指的就是这台公网服务器
端口号是7689,后面会用这个跟内网来进行通信
upstream tunnel { server 127.0.0.1:7689; }
- nginx.conf添加内容
```nginx
server { listen 80; server_name x.xx.xxx;
location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off;
proxy_pass http://tunnel;
} }
- 内网服务器- 使用ssh打开一个通道- ssh -vnNT -R 服务器端口:localhost:本地端口 服务器用户名@服务器 IP 地址- **如:**ssh -vnNT -R 7689:localhost:8000 root@47.45.14.12- 7689指的是公网服务器的端口,localhost:8000是内网服务器的ip端口- root是公网服务器的用户,47.45.14.12是公网服务器的ip- **self:**ssh -vnNT -R 7788:localhost:3306 root@47.106.103.145- 所以:- 当我们访问[http://x.xx.xxx](https://link.zhihu.com/?target=http%3A//x.xx.xxx)的时候,得到的响应是你内网服务器上的服务(会把请求转到服务器上的7968端口,这个端口跟我们内网环境上的8000端口是连接到一块的)- 注意- 内网映射自己公网IP云服务器搭建用nginx或SSH都可以,可以留意一些内存溢出情况加个脚本自动重启下执行。- 内网映射无公网IP环境,可以直接通过nat123将本地内网IP端口映射到自己域名来外网访问。<a name="1VDuV"></a># 小功能<a name="NTOY9"></a>## 管理员cmd- 添加管理员cmd- 新建文本文件,命名cmdCreate.reg(注册表文件)- 双击运行- 如果出现编码问题,就把编码改成**ANSI**- 创建代码```shellWindows Registry Editor Version 5.00; Created by: Shawn Brink; http://www.sevenforums.com; Tutorial: http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html[-HKEY_CLASSES_ROOT\Directory\shell\runas][HKEY_CLASSES_ROOT\Directory\shell\runas]@="命令行(管理员)""HasLUAShield"=""[HKEY_CLASSES_ROOT\Directory\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas][HKEY_CLASSES_ROOT\Directory\Background\shell\runas]@="命令行(管理员)""HasLUAShield"=""[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""[-HKEY_CLASSES_ROOT\Drive\shell\runas][HKEY_CLASSES_ROOT\Drive\shell\runas]@="命令行(管理员)""HasLUAShield"=""[HKEY_CLASSES_ROOT\Drive\shell\runas\command]@="cmd.exe /s /k pushd \"%V\""
- 取消功能 ```shell Windows Registry Editor Version 5.00
; Created by: Shawn Brink
; Tutorial: http://www.sevenforums.com/tutorials/47415-open-command-window-here-administrator.html
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
[-HKEY_CLASSES_ROOT\Drive\shell\runas] ```
