티스토리 뷰


Nginx의 proxy설정 및 파일 위치 지정법입니다



기본 설치 시에 셋팅 파일은 /etc/nginx/nginx.conf에 위치 하고 있습니다. 

하지만 저희는  /etc/nginx/conf.d/default.conf 여기서 파일을 수정하면 됩니다. 

nginx.conf에서 default.conf를 include하고 있으니까요! 


해당 파일을 확인해 보면 아래처럼 나와있는데요 해당 부분을 수정해 주면 됩니다. 

설정 후에는 systemctl restart nginx 명령어로 Nginx를 재 시작 해야 합니다. 



server {

    listen       80;

    server_name  localhost;


    #charset koi8-r;

    #access_log  /var/log/nginx/log/host.access.log  main;


    # Front파일이 위치한 폴더를 root에 명시해 줍니다. (기본적으로 이곳에 index파일이 존재해야합니다.)

    # 파일 빌드시 index파일에 실행 정보가 있으니까요! 

    # proxy설정 시, Gateway에러를 방지하기 위해 time-out설정을 해 줍니다. 

    location / {

        #root   /usr/share/nginx/html;

        root    /home/test/dist;

        index  index.html index.htm;

        try_files $uri $uri/ /index.html;

        proxy_connect_timeout 300;

        proxy_send_timeout 300;

        proxy_read_timeout 300;

        send_timeout 3000;

    }

    #error_page  404              /404.html;


    # redirect server error pages to the static page /50x.html

    #

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {

        root   /usr/share/nginx/html;

    }


 

    # back-end와의 연결을 위해 proxy설정을 해 줍니다 

    #

    location /api/ { 

        proxy_pass   http://ip주소:port번호;

    }


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    #location ~ \.php$ {

    #    root           html;

    #    fastcgi_pass   127.0.0.1:9000;

    #    fastcgi_index  index.php;

    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

    #    include        fastcgi_params;

    #}


    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}






공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함