代码之家  ›  专栏  ›  技术社区  ›  Edito

如何配置nginx的default.conf

  •  2
  • Edito  · 技术社区  · 7 年前

    我正在尝试配置 default.conf 在里面 /etc/nginx/conf.d 显示位于以下位置的简单登录页 /home/ubuntu/project-source/company/entry/index.html .

    据我所知,域设置正确,可以指向服务器

    A: test24.company.io -> <aws-elastic-IP>
    

    默认.conf:

    server {
        listen       80;
        server_name  localhost;
    
        index index.html;
    
        location / {
            root   /home/ubuntu/project-source/company/entry;
        }
    }
    
    server {
        server_name test24.company.io www.test24.company.io;
    
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/test24.company.io/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/test24.company.io/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    }
    
    server {
        if ($host = test24.company.io) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
    
        listen      80;
        server_name test24.company.io www.test24.company.io;
        return 404; # managed by Certbot
    }
    

    附加问题:项目将在2个子域上运行2个进程,比如说 sub1 sub2 它们会继续奔跑 localhost:3001 localhost:3002 分别,如何配置 默认.conf 指向/代理这些进程?

    2 回复  |  直到 7 年前
        1
  •  1
  •   Ahmed Abdelazim    7 年前

    server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com; 
    return 301 https://example.com$request_uri;
    }
    

    root   /home/ubuntu/project-source/company/entry;
    

    sudo service nginx restart
    
        2
  •  0
  •   Edito    7 年前


    1. A: test24.company.io -> <aws-elastic-IP>
      A: sub1.test24.company.io -> <aws-elastic-IP>
      A: sub2.test24.company.io -> <aws-elastic-IP>

    2. https://gist.github.com/ahmed-abdelazim/b3536c1780afc4215ef57633bbe77a88

    This