文章目录
-
- 由于是要访问一个公网地址,假如需要访问的地址为: www.emperinter.info 。 nginx 安装 nginx配置 worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; resolver 8.8.8.8; location / { proxy_pass https://www.emperinter.info/; proxy_set_header Host $proxy_host; } access_log /usr/local/nginx_1/logs/access.log; error_log /usr/local/nginx_1/logs/error.log; } } 连通性测试,如果能够下载到index.html文件,说明配置成功。如果没有,请注意看nginx日志进行排查。 wget http://127.0.0.1 more index.html
- 添加并修改/etc/hosts如下: 127.0.0.1 www.emperinter.info 测试配置是否成功! wget https://www.emperinter.info/ more index.html

最近碰到一个需求,有两个服务器,两个服务器可以互联,一个可以连接外网,一个不能。但部署的服务在内网机器上,但又需要写个脚本调用外部的一个接口,最后同通过nginx正向代理出来了。
| IP | 内/外网 |
|---|---|
| 127.0.0.1 | 外网 |
| 127.0.0.2 | 内网 |
由于是要访问一个公网地址,假如需要访问的地址为: www.emperinter.info 。
-
nginx 安装
-
nginx配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
resolver 8.8.8.8;
location / {
proxy_pass https://www.emperinter.info/;
proxy_set_header Host $proxy_host;
}
access_log /usr/local/nginx_1/logs/access.log;
error_log /usr/local/nginx_1/logs/error.log;
}
}
- 连通性测试,如果能够下载到
index.html文件,说明配置成功。如果没有,请注意看nginx日志进行排查。
wget http://127.0.0.1
more index.html
由于是要访问一个公网地址,假如需要访问的地址为: www.emperinter.info 。
nginx 安装
nginx配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
resolver 8.8.8.8;
location / {
proxy_pass https://www.emperinter.info/;
proxy_set_header Host $proxy_host;
}
access_log /usr/local/nginx_1/logs/access.log;
error_log /usr/local/nginx_1/logs/error.log;
}
}
index.html文件,说明配置成功。如果没有,请注意看nginx日志进行排查。wget http://127.0.0.1
more index.html
- 添加并修改
/etc/hosts如下:
127.0.0.1 www.emperinter.info
- 测试配置是否成功!
wget https://www.emperinter.info/
more index.html
/etc/hosts如下:127.0.0.1 www.emperinter.info
wget https://www.emperinter.info/
more index.html
