package http
import "net/http"
const nginx401Page = `<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>`
const nginx403Page = `<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>`
const nginx404Page = `<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>`
const nginx405Page = `<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>`
const nginxInternalServerErrorPage = `<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>`
const nginxTail = `
<hr><center>nginx/1.24.0</center>
</body>
</html>`
func (h *httpHoneypot) writeNginxError(w http.ResponseWriter, status int) {
h.setResponseHeaders(w)
w.Header().Set("Content-Type", "text/html")
w.Header().Del("cache-control")
w.WriteHeader(status)
switch status {
case http.StatusUnauthorized:
w.Write([]byte(nginx401Page + nginxTail))
case http.StatusForbidden:
w.Write([]byte(nginx403Page + nginxTail))
case http.StatusNotFound:
w.Write([]byte(nginx404Page + nginxTail))
case http.StatusMethodNotAllowed:
w.Write([]byte(nginx405Page + nginxTail))
default:
w.Write([]byte(nginxInternalServerErrorPage + nginxTail))
}
}