Nginx多端口转发文件配置
服务器使用非80端口访问需要加端口号还是很难受的,使用域名解析来绑定也比较不划算,例如阿里云免费版的匿名转发url服务只有两个,如果使用Nginx进行转发,还是很爽的。
只需要将所有的二级域名解析到服务器的IP(阿里云域名解析到IP是没多大限制的),用Nginx进行识别访问的域名,进行转发,体验不输域名解析服务。这里给出目前在用的配置文件示例
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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;
tcp_nopush on;
tcp_nodelay on;

本文介绍如何使用Nginx进行多端口转发,通过配置文件实现不同二级域名的解析与转发,提高服务器访问体验。展示了具体的Nginx配置示例,包括监听端口、域名匹配、根目录设置等。
最低0.47元/天 解锁文章
9996

被折叠的 条评论
为什么被折叠?



