一、基础环境
操作系统:Microsoft Windows Server 2019 datacenter (64位)
Nginx 版本:nginx/1.21.4
数据库版本:Oracle Database 11.2.0.4.0
二、适用场景
在多网络环境中,有时候我们不能直接访问 Oracle 数据库服务,可以通过使用前置机上运行 nginx 代理 Oracle 数据库服务端口,达到访问 Oracle 数据库服务的目的。
三、操作步骤
Oracle 数据库服务端口:192.168.1.100:1521
前置机服务器的物理IPv4:192.168.1.200,映射IPv4:10.28.1.100
在前置机服务器上安装 Nginx ,核心配置文件 conf/nginx.conf 配置内容如下:
# nginx 核心配置文件
# 2022-2-11 yangqun2010@foxmail.com
worker_processes 1;
# 错误日志路径
error_log logs/error.log;
error_log logs/error.log notice;
events {
worker_connections 1024;
}
stream {
server {
# 监听端口
listen 1522;
# 代理的地址及端口
proxy_pass 192.168.1.100:1521;
}
}
保存配置和启动 nginx 后,我们就可以通过 192.168.1.200:1522 和 10.28.1.100:1522 来访问Oracle 数据服务(192.168.1.100:1521 )了。