曾彪彪的个人网站
首页
文章列表
>>
文章详情
Multiple domain listen the same port in Nginx
作者:
曾彪彪
日期:
2020-03-26 02:40:12
阅读(291)
分类:
运维&部署
If you need to use Nginx for multiple domain proxy, there are several solution for this. The most popular solution is to create different configuration file for each domain, and then add symbolic link. Please refer [How to configure Multiple Domains with Nginx on Ubuntu](https://www.serverlab.ca/tutorials/linux/web-servers-linux/how-to-configure-multiple-domains-with-nginx-on-ubuntu/) Since we run Nginx in a container, so we will create multiple configuration for each domain. 1. Run Nginx ```shell docker run -d --name nginx -p 80:80 -v /home/sam/nginx/config/nginx:/etc/nginx nginx ``` 2. Create Configuration File under ""/home/sam/nginx/config/nginx/conf.d". All *.conf file are added to nginx configuration by default. ```shell touch example.com.conf cat << 'EOF' >> example.com.conf server { listen 80; server_name r1.zengbiaobiao.com; client_max_body_size 2000M; location / { proxy_pass http://192.168.1.101:5000; } } EOF docker restart nginx ``` 3. Test it. If you access localhost, it will return the Nginx default welcome page, If you access example.com, it will forward to http://192.168.1.101:5000. ```shell curl example.com curl localhost ```
评论(0)
评论(必填)
名称(必填)
联系方式(可选)
验证码(必填)
提交
评论(必填)
名称(必填)
联系方式(可选)
验证码(必填)