报错代码
414
解决方法
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
.....
http{
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
......
}
414
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
.....
http{
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
......
}
在设置 Nginx 认证以后才能登录网页之前要先安装 Nginx
# yum -y install httpd-tools
# htpasswd -c /usr/local/nginx/pass zhumingyu1
(补充:这里以删除原来的所有用户新增 zhuming1 用户为例)
# htpasswd /usr/local/nginx/pass zhumingyu2
(补充:这里以新增 zhumingyu2 用户为例)
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
server {
listen 80;
server_name localhost;
auth_basic "input password";
auth_basic_user_file “/usr/local/nginx/pass”;
location /{
root html;
root html;
index index.html index.htm;
}
......
}
......
# /usr/local/nginx/sbin/nginx
(步骤略)
(补充:可以输入刚刚添加的 zhumingyu1 和 zhumingyu2 的用户名和密码)
在添加 Nginx 域名、IP 地址或端口的虚拟机主机之前要先安装 Nginx
# vim /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
Server {
Listen 80;
Server_name www.eternlcenter.com;
Location / {
Root www;
Index index.html index.html;
}
}
......
(补充:这里以将本地的 80 端口设置为 www.eternalcenter.com 的虚拟机为例)
在设置 Nginx 重定向之前要先安装 Nginx
# cd /usr/local/nginx/conf
# openssl genrsa > cert.key
# openssl req -new -x509 -key cert.key > cert.pem
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
server {
listen 443
server_name www.c.com;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
location /{
root html;
index index.html index.htm;
}
......
}
......
在设置 Nginx 代理之前要先安装 Nginx
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
http {
.....
upstream webserver {
server 192.168.1.100:80;
server 192.168.1.200:80;
}
.....
server {
listen 80;
server_name www.eternalcenter.com;
location / {
proxy_pass http://webserver;
}
......
}
......
}
或者:
......
http {
.....
upstream webserver {
Server 192.168.2.100 weight=1 max_fails=1 fail_timeout=30;
Server 192.168.2.200 weight=2 max_fails=2 fail_timeout=30;
Server 192.168.2.101 down;
}
.....
server {
listen 80;
server_name www.eternalcenter.com;
location / {
proxy_pass http://webserver;
}
......
}
......
}
将部分内容修改如下:
stream {
upstream backend {
server 192.168.1.100:22;
server 192.168.1.200:22;
}
server{
listen 222;
proxy_connect_timeout 1s;
proxy_pass backend;
}
}
http{
......
}