서블릿 ( Servlet )
- 자바를 기반으로 웹 서버에서 실행되는 서버 측 프로그램
- 클라이언트의 요청을 처리하고 그에 대한 응답을 생성하는 역할(req,res)을 한다.
- javax.servlet 패키지에 정의된 인터페이스를 구현하여 작성
- 초기화(init), 요청 처리(service), 종료(destroy)의 생명주기를 가진다.
- *WAS(Web Application Server)에서 관리
WAS ( Web Application Server )
- 웹 클라이언트의 요청을 처리하고 데이터베이스나 서버 로직과 연동하여 동적인 웹 컨텐츠를 생성해주는 서버 소프트웨어
- HTTP 요청을 받아 서블릿, JSP, Spring 같은 웹 애플리케이션 컴퍼넌트를 실행하고, 그 결과를 HTML 형태로 클라이언트에게 응답 ( *웹 서버 + Java의 중요로직 → html로 변환해주고 사용자에게 그 정보를 넘겨주는 역할 )
- Apache Tomcat (실무에서는 웹서버 사용 후에 Apache 연동하여 사용)
- Jetty
- JBoss
- WebLogic
- WebSphere
< 연결 구조 >
(req , res)
[ browser ] ↔ [ WebServer ] ↔ [ WAS ] ← ( DB )
cf. 웹 서버 ( Web Server )
클라이언트의 요청을 받아, 정적인 리소스 (HTML, CSS, Images, JS etc..)를 클라이언트에게 그대로 반환하는 역할
- Apache HTTP 서버
- NginX
- Microsoft IIS (주로, 윈도우)
# 설치 - NginX
if. Mac 설치
brew install nginx
nginx
nginx nginx ("engine x") is an HTTP web server, reverse proxy, content cache, load balancer, TCP/UDP proxy server, and mail proxy server. Originally written by Igor Sysoev and distributed under the 2-clause BSD License. Enterprise distributions, commercial
nginx.org
설치 파일 확인!
폴더에서 nginx.exe를 실행하거나, 명령 프롬프트에서 start nginx
* Nginx 재시작
- niginx -s quit 또는 nginx -s stop
- ngin -s reload
* NginX 실행 중 확인
- tasklist | findstr nginx
# 설정 파일
- CONF 파일을 VsCode로 엶
#user nobody;
#CPU의 core : CPU가 일할 수 있는 단위 --> c분할 가능 (병렬처리 가능으로 작동 시간 단축)
#Thread : 작업 단위
worker_processes 2;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#워커프로세스 1개가 1024개의 프로세스를 돌린다. --> 곱하기 연산으로 처리
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
#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;
#클라이언트가 연결을 유지하는 시간(재연결X)
keepalive_timeout 65;
#gzip on;
server {
#port 번호
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#기본페이지 처리
location / {
root html;
index index.html index.htm;
}
#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 localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
< 팀 프로젝트 >
WebRTC (Web Real-Time Communication)
: 웹 브라우저 간에 플러그인의 도움 없이 서로 통신할 수 있도록 설계된 API
NginX 실행 및 종료
- cd C:nginx파일경로
- nginx -s quit (정상종료)
- nginx -s stop (강제종료)
'Backend > Servlet' 카테고리의 다른 글
Tomcat9 (0) | 2025.06.10 |
---|---|
Servlet (0) | 2025.06.09 |
Session & Servlet api (0) | 2025.06.05 |
Maven 프로젝트 (0) | 2025.06.04 |
Servlet _ Apache Tomcat _ Install (0) | 2025.06.02 |