반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 프로그래밍언어론
- 오블완
- springboot
- AI
- swift
- 스프링부트 웹 소켓
- 아이패드다이어리
- 오라클
- 리눅스
- CI
- 소켓
- CD
- 데이터베이스
- sql
- IOS
- jenkins
- 42seoul
- libasm
- DBMS
- 다이어리
- 인공지능
- 네트워크
- 스프링부트
- Spring
- JPA
- javascript
- Xcode
- MySQL
- 스프링
- 티스토리챌린지
Archives
- Today
- Total
Hi yoahn 개발블로그
[42Seoul/ft_server] nginx 설정파일 (autoindex / ssl / redirect 설정) 본문
42 SEOUL/배운 것들 정리
[42Seoul/ft_server] nginx 설정파일 (autoindex / ssl / redirect 설정)
hi._.0seon 2021. 2. 16. 16:04반응형
server {
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
- listen
nginx에게 http 연결을 위해 필요한 hostname/IP 와 TCP 포트를 알려준다 - listen 80
http 연결을 위한 80번 포트에 대해 동작
IPv4 HTTP 패킷을 리다이렉션 - listen [::]:80
모든 IPv6 HTTP 트래픽에 대해 작동 - return 301 https://$host$request_uri;
- 301 : HTTP 응답 상태 코드. 영구적인 URL 리다이렉션을 위해 사용됨
- $host$request_uri : domain 주소 + 클라이언트가 요청한 url
server {
# SSL configuration
listen 443 ssl;
listen [::]:443 ssl;
# ssl setting
ssl on;
ssl_certificate /etc/ssl/certs/localhost.dev.crt;
ssl_certificate_key /etc/ssl/private/localhost.dev.key;
# server root directory config
root /var/www/html;
# Add index.php to the list if you are using PHP
# Auto index
index index.html index.htm index.nginx-debian.html index.php;
server_name ft_server;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
autoindex on;
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}
- ssl을 사용한다고 listening sockets에 파라미터로 적어둔다
- ssl 인증서와 비공개키의 위치를 적어둔다.
- location 블록
서버 안의 리소스에 대한 요청을 어떻게 응답해야 할지를 설정
특정 파일과 특정 디렉토리에 대한 요청을 처리함 - location ~ \.php$
~ : 정규 표현식 매치를 수행
.php 로 끝나는 모든 요청들은 이 블럭에 의해 처리됨 - include snippets/fastcgi-php.conf;
fastcgi-pass unix:/run/php/php7.3-fpm.sock; - autoindex
루트 디렉토리에 있는 파일들을 자동으로 연결해 주는 것 - try_files $uri $uri/ =404;
root 폴더 내에 uri에 따른 폴더가 있는지 찾아보고 없으면 404 에러 - server_name 은 방문자가 들어온 주소에 따라 해당 도메인 이름을 가진 server 블록이 요청을 처리함
fastcgi_pass 는 php-fpm 과 Nginx 를 연결하기 위한 인터페이스를 지정하는 것
php-fpm의 listen 설정값과 일치해야 한다.
include snippets/fastcgi-php.conf;
fastcgi_pass
-> php 스크립트를 FastCGI 서버로 보내는 것
보내기 위한 설정파일을 include 하고,
소켓 경로를 적어둔다.
architectophile.tistory.com/12
[Nginx] 기본 설정 방법
[Nginx] 기본 설정 방법 Nginx는 가벼운 고성능의 웹서버로서 높은 트래픽 처리를 위해 디자인되었다. Nginx의 가장 강력한 기능 중 하나는 HTML이나 미디어 파일 같은 정적 컨텐츠를 효율적으로 서브
architectophile.tistory.com
나는 nginx 설정이 정말 싫다구요
nginx 설정 nginx.conf와 conf.d를 알아보자
juneyr.dev
반응형
'42 SEOUL > 배운 것들 정리' 카테고리의 다른 글
[42Seoul/exam] exam02 공부 (0) | 2021.03.18 |
---|---|
[42Seoul/Cub3d] #1 cub3d 시작하기 (0) | 2021.03.12 |
[42Seoul/ft_server] php, autoindex (0) | 2021.02.13 |
[42Seoul/ft_server] docker 와 docker file (0) | 2021.02.10 |
[42SEOUL/ft_server] Nginx 란? (0) | 2021.02.04 |
Comments