Nginx 설정 (nginx.conf 파일)
listen: 80번 포트로 요청을 받음
server_name: 요청이 들어오는 서버 도메인 주소
이렇게 들어오는 모든 요청을 스프링부트 프론트 서버 포트인 8081으로 포워딩 되도록 설정했다.
SSL 적용전(Http)
server {
listen 80;
server_name www.sikyeojo.shop; #도메인 주소
location / {
proxy_pass http://127.0.0.1:8081;
}
}
SSL 적용 후(Https)
server {
listen 80;
server_name www.sikyeojo.shop;
# HTTP 요청을 HTTPS로 리다이렉트
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name www.sikyeojo.shop;
ssl_certificate crt.pem 경로;
ssl_certificate_key key.pem 경로;
ssl_trusted_certificate chain.pem 경로;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8081;
}
location /phpMyAdmin {
root "C:/Users/dlrud/Desktop/infra/nginx/html";
index index.php;
try_files $uri $uri/ /phpMyAdmin/index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME "C:/Users/dlrud/Desktop/infra/nginx/html/phpMyAdmin/index.php";
include fastcgi_params;
}
}
}
Apache + MySQL phpMyAdmin 구축 방법
https://admd13.tistory.com/118
nginx - 윈도우에서 무료 SSL 발급 및 적용하기 (Let's Encript ACME For Windows)
출처: https://luvris2.tistory.com/916 [고은별의 기술 공유 연구소:티스토리]
Nginx 와 PHP-CGI 서비스 등록 (feat.nssm)
출처: https://8ugust-dev.tistory.com/23
[발생한 오류]
Windows에서 아파치 서비스 시작 에러(httpd.conf Syntax 검사 수행)
https://blog.naver.com/PostView.nhn?blogId=s0215hc&logNo=220333412845
#user nobody;
worker_processes auto;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 10M;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.eventor.store;
client_max_body_size 10M;
# HTTP 요청을 HTTPS로 리다이렉트
return 301 https://$host$request_uri;
# location / {
# proxy_pass http://127.0.0.1:8081;
# }
# location /phpMyAdmin {
# root "C:/Users/dlrud/Desktop/infra/nginx/html";
#
# index index.php;
#
# try_files $uri $uri/ /phpMyAdmin/index.php;
#
# location ~ \.php$ {
# root "C:/Users/dlrud/Desktop/infra/nginx/html/phpMyAdmin";
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
# }
# }
# 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 html;
# }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# 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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen 443 ssl;
server_name www.eventor.store;
client_max_body_size 10M;
ssl_certificate C:/Users/dlrud/Desktop/infra/SSL-Certification/www.eventor.store-crt.pem;
ssl_certificate_key C:/Users/dlrud/Desktop/infra/SSL-Certification/www.eventor.store-key.pem;
ssl_trusted_certificate C:/Users/dlrud/Desktop/infra/SSL-Certification/www.eventor.store-chain.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8081;
client_max_body_size 10M;
}
location /phpMyAdmin {
root "C:/Users/dlrud/Desktop/infra/nginx/html";
index index.php;
try_files $uri $uri/ /phpMyAdmin/index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME "C:/Users/dlrud/Desktop/infra/nginx/html/phpMyAdmin/index.php";
include fastcgi_params;
}
}
# /postimage 요청을 Windows의 실제 파일 경로로 매핑
location /postimage/ {
root C:/Users/dlrud/Desktop/infra; # 실제 디렉토리의 루트 경로
}
# 8070 포트로 들어오는 요청을 처리하도록 추가
location /oauth2/ {
proxy_pass http://localhost:8070/oauth2/; # 8070 포트로 리다이렉트
}
}
}