imort 박뉴프

Nginx - 웹사이트 크롤링 거부 본문

Develop/Error Correction

Nginx - 웹사이트 크롤링 거부

박뉴프 2022. 11. 10. 09:57

1) 설정 파일

 

nginx.conf

	server {
        listen       80;
        server_name  hello.userinsight.co.kr;
		
		location /robots.txt {
			return 200 "User-agent: *\nDisallow: /";
		}

		location / {
			proxy_pass http://localhost:0000/;
			proxy_something...
		}
    }

 

2) 설정 파일

robot.txt 

 

아래와 같은 컨피그를 nginx-app.conf에 넣고 도커화를 할때에, 적용만 해주면 된다.

location /robots.txt {
    return 200 "User-agent: *\nDisallow: /";
}

팁으로 Django app 레벨에서, 해주는 경우도 있다. (파이서닉한 방법이다.)

from django.http import HttpResponseurl(r'^robots.txt', lambda x: HttpResponse("User-Agent: *\nDisallow: /", content_type="text/plain"), name="robots_txt")

🔍 블로그 https://parkmj236.tistory.com

🔍 Notion 이력서 https://parkmj236.notion.site/Park-Minji-e4fa8aa44b8c48b582a9082515dbc15e

🔍 Github https://github.com/Park-New-project/Projects


참고

 

'Develop > Error Correction' 카테고리의 다른 글

NodeJS MySQL [ER_NOT_SUPPORTED_AUTH_MODE] 오류  (0) 2024.01.21
HTTP 403 - HTTP 크롤링 오류  (0) 2022.10.15
Comments