在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
为了不让域名fangyuanxiaozhan.com闲置, 作者又买了个国内的虚拟主机(VPS)的ip为 我的vps挂了三个服务, 分别是:
我的需求:
实现的方法 1、到托管域名的网站, 添加DNS解析, 我的域名 fangyuanxiaozhan.com 托管在阿里云, 我的做法是登录 https://dns.console.aliyun.com/#/dns/domainList , 添加二级记录
2、我使用的是centos7, 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/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; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; } 注意上述配置文件的最后一行, 在
blog.conf (实现8000端口映射到80端口, 不使用二级域名) server { listen 80; server_name fangyuanxiaozhan.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://0.0.0.0:8000; } } blog.conf实现了fangyuanxiaozhan.com:8000映射到 fangyuanxiaozhan.com git.conf (实现10080端口映射到80端口, 使用二级域名 server { listen 80; server_name git.fangyuanxiaozhan.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://0.0.0.0:10080; } } git.conf实现了fangyuanxiaozhan.com:10080映射到 git.fangyuanxiaozhan.com nc.conf (实现10080端口映射到80端口, 使用二级域名 server { listen 80; server_name cloud.fangyuanxiaozhan.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://0.0.0.0:8080; } } git.conf实现了fangyuanxiaozhan.com:8080映射到 cloud.fangyuanxiaozhan.com 重启nginx使配置生效 关闭nginx sudo $(which nginx) -s stop 开启nginx sudo $(which nginx) 效果展示
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持极客世界。 |
请发表评论