nextjs - nginx config

sangwoo noh·2022년 8월 3일
0

nginx

목록 보기
2/4

경로

  • admin.videohelp.me.conf라는 내가 올릴 nginx용 설정파일을 추가한다.
    (이름은 마음대로 지어도됨)
/etc/nginx/sites-enabled/admin.videohelp.me.conf 

설정 내용

server {
    listen 80;
	server_name mynextjs.project.com;
	if ($host = 'mynextjs.project.com') {
		return 301 https://mynextjs.project.com$request_uri;
	}
	return 301  https://$host$request_uri;
}

server {
    listen 443;
    server_name mynextjs.project.com;
    ssl on;
    access_log /var/log/nginx/mynextjs.project.com.ssl.access.log;

    client_max_body_size 20M;
    client_body_buffer_size 512k;

    ssl_certificate /etc/nginx/conf.d/dev/wildcard-videohelp-me-2022-12-03-nginx.crt;
    ssl_certificate_key /etc/nginx/conf.d/dev/wildcard-videohelp-me-2022-12-03-nginx.key;

    #ssl_protocols SSLv3 TLSv1.2;
    ssl_protocols TLSv1.2;
    ssl_ciphers RC4:HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    keepalive_timeout    60;
    #ssl_session_cache    shared:SSL:10m;
    ssl_session_timeout  10m;

    location / {
        limit_except GET POST DELETE {
        deny all;
        }
        if ($request_method = 'OPTIONS') {
            #add_header 'Access-Control-Allow-Origin' '*';

            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST';

            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,authorization';

            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'x-frame-options' 'SAMEORIGIN';
            add_header 'Content-Length' 0;
            add_header 'Referrer-Policy' 'origin';
            return 204;
        }

        #limit_except GET POST DELETE{
        #	deny all;
        #}
        if ($request_method = 'POST') {
            #add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST';
            add_header 'Referrer-Policy' 'no-referrer-when-downgrade';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,authorization';
            #add_header X-Frame-Options deny;
            #add_header 'x-frame-options' 'SAMEORIGIN';
            #add_header 'X-Frame-Options' 'ALLOW-FROM https://mynextjs.project.com/';			
        }
        if ($request_method = 'GET') {
            #add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST';
            add_header 'Referrer-Policy' 'no-referrer-when-downgrade';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,authorization';
            #add_header 'X-Frame-Options' 'deny';
            add_header 'x-frame-options' 'SAMEORIGIN';
            #add_header 'X-Frame-Options' 'ALLOW-FROM https://mynextjs.project.com/';			
        }
        proxy_set_header Accept-Encoding   "";
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Server $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 https;
        proxy_set_header X-Forwarded-Port 443;
        add_header Front-End-Https on;
        add_header x-frame-options SAMEORIGIN;
        proxy_set_header X-Scheme https;
        proxy_set_header Refer $http_refer;
        real_ip_header X-Forwarded-For;
        set_real_ip_from 0.0.0.0/0;
        proxy_redirect     off;
        proxy_intercept_errors on;
        proxy_pass http://localhost:3000;
    }
}
profile
하기로 했으면 하자

0개의 댓글