[deploy] nginx.conf設定

5559 ワード

http{}の構造

server {
        listen 80;
        server_name i6a206.p.ssafy.io;
        location / {
                return 301 https://$host$request_uri;
        }
}

server {
        listen 443 ssl;
        server_name i6a206.p.ssafy.io;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ssl_certificate /etc/letsencrypt/live/i6a206.p.ssafy.io/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/i6a206.p.ssafy.io/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv3;
        ssl_ciphers ALL;


        location / {
                root /home/ubuntu/client/dist;
                index index.html index.htm;
                charset utf-8;
                try_files $uri $uri/ /index.html;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                  proxy_set_header X-Nginx-Proxy true;
        }

        location /api {
                rewrite ^/api/(.*|$) /$1 break;
                proxy_pass https://127.0.0.1:8080;
                proxy_redirect off;
                charset utf-8;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Nginx-Proxy true;
        }

        location /openvidu {
                proxy_pass http://127.0.0.1:5443;
                proxy_redirect off;
                charset utf-8;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;

        }
}
sudo vi/opt/openvidu/.env