본문 바로가기
Tool/WEB,WAS

nginx default.conf

by 하하IT 2019. 4. 10.

1. vi /etc/nginx/nginx.conf 

 

#
# The default server
#
server {
  listen  80;
  server_name test1.test.com;
  root /opt/www/test1;
  location / {
    try_files $uri $uri/ =404;
  }
}

#############################################

server {
 listen 80;
 server_name test2.test.com;
 root /opt/www/test2;
 location / {
    try_files $uri $uri/ =404;
 }
}

############################################

server {
 listen 80;
 server_name test3.test.com;
 location / {
    proxy_pass http://localhost:3000/test3;
 }
}

#############################################

 


#################################################################

server {

            server_name test1.test.com;
            location / {
                        proxy_set_header HOST $host;
                        proxy_pass http://127.0.0.1:8080;
                        proxy_redirect off;
           } 
            listen 443 ssl;
  access_log /var/log/nginx/proxy/test1.test.com_access.log;
  error_log /var/log/nginx/proxy/test1.test.com_error.log;
       ssl_certificate /etc/letsencrypt/live/test1.test.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/test1.test.com/privkey.pem;
            include /etc/letsencrypt/options-ssl-nginx.conf;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {

            server_name test2.test.com;
            location / {
                        proxy_set_header HOST $host;
                        proxy_pass http://127.0.0.1:9090;
                        proxy_redirect off;
           } 
            listen 443 ssl;
  access_log /var/log/nginx/proxy/test2.test.com_access.log;
  error_log /var/log/nginx/proxy/test2.test.com_error.log;
       ssl_certificate /etc/letsencrypt/live/test2.test.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/test2.test.com/privkey.pem;
            include /etc/letsencrypt/options-ssl-nginx.conf;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {

            server_name test3.test.com;
            location / {
                        proxy_set_header HOST $host;
                        proxy_pass http://127.0.0.1:18080;
                        proxy_redirect off;
           } 
            listen 443 ssl;
  access_log /var/log/nginx/proxy/test3.test.com_access.log;
  error_log /var/log/nginx/proxy/test3.test.com_error.log;
       ssl_certificate /etc/letsencrypt/live/test3.test.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/test3.test.com/privkey.pem;
            include /etc/letsencrypt/options-ssl-nginx.conf;
            ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
     
# 80포트로 들어와도 443으로 꺾어줘야 돼

server {

            server_name  test1.test.com  test2.test.com  test3.test.com  ;

            listen 80;
            return 301 https://$host$request_uri;

}

#################################################################

 

#############################################

 

2. systemctl restart  nginx 

'Tool > WEB,WAS' 카테고리의 다른 글

tomcat / catalina.out / 일자별 log  (0) 2021.10.05
Jboss 7.1.1 as Windows service  (0) 2020.04.27
WAS / jBoss 7.1  (0) 2020.04.24
WAS / jboss 5.1 Administration Console password change  (0) 2020.04.24
centos / nginx / install nginx on centos 7  (0) 2019.04.10