nginx 代理 TCP 端口 完整配置文件
时间: 2023-07-24 21:44:48 浏览: 103
下面是一个完整的Nginx配置文件示例,用于代理TCP端口:
```
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
stream {
server {
listen 1234;
proxy_pass backend_server:1234;
}
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
```
在上面的配置文件中,stream块用于配置TCP代理,http块用于配置HTTP服务。需要注意的是,上面的配置仅用于示例,实际应用中需要根据自己的需求进行配置。
阅读全文