请帮我输出一个完整的nginx.conf配置文件 要求: 1、nginx作为转发服务器 2、监听443和8107端口,其中443用于出网转发到swg.sensorsdata.cn,8107作为web页面转发到10.170.19.84服务器
时间: 2024-04-24 15:23:03 浏览: 21
下面是一个符合您要求的示例nginx.conf配置文件:
```nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /path/to/ssl_certificate.crt;
ssl_certificate_key /path/to/ssl_certificate.key;
location / {
proxy_pass https://swg.sensorsdata.cn;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 8107;
server_name yourdomain.com;
location / {
proxy_pass http://10.170.19.84;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
```
请将 `yourdomain.com` 替换为您的域名,并根据您的实际情况设置 SSL 证书路径 `/path/to/ssl_certificate.crt` 和私钥路径 `/path/to/ssl_certificate.key`。
这个配置文件中定义了两个服务器块,分别监听443和8107端口。第一个服务器块将请求代理到 `https://swg.sensorsdata.cn`,第二个服务器块将请求代理到本地服务器 `http://10.170.19.84`。其中,443端口用于出网转发,8107端口用于web页面转发。
请注意,以上只是一个示例配置文件,实际的配置可能需要根据您的具体需求进行调整。