nginx环境搭建

nginx安装步骤

安装nginx
[root@insure opt]# yum install nginx
启动nginx
[root@insure opt]# service nginx start
Redirecting to /bin/systemctl start nginx.service
测试nginx是否安装成功
[root@insure opt]# wget http://127.0.0.1
---- ::-- http://127.0.0.1/
Connecting to 127.0.0.1:... connected.
HTTP request sent, awaiting response... OK
Length: (.6K) [text/html]
Saving to: ‘index.html’ %[==================================================================================================================================================================>] , --.-K/s in 0s -- :: ( MB/s) - ‘index.html’ saved [/]

nginx操作

查看安装目录
[root@insure nginx]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx..gz /usr/share/man/man3/nginx.3pm.gz
[root@insure nginx]# cd /etc/nginx/
[root@insure nginx]# ls
conf.d fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
default.d fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default

添加前端启动的配置  vi nginx.conf

server {
listen default_server;
#listen [::]: default_server;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

#主要配置这里
location / {
root /opt/dev/claimconf/dist;
index index.html index.html;
try_files $uri $uri/ @router;
} location @router {
rewrite ^.*$ /index.html last;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

server {
listen 9000 default_server;
#listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;


# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;


location / {
root /opt/dev/claimconf/dist;
index index.html index.html;
try_files $uri $uri/ @router;


}


location @router {
rewrite ^.*$ /index.html last;
}


error_page 404 /404.html;
location = /40x.html {
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

 

修改完成保存 重启nginx

service nginx restart 或者nginx -s reload

由于带宽原因,有两台nginx,最外层一台配置为

添加配置文件vi /etc/nginx/conf.d/standardprod.conf

server
{
listen ;
server_name standardtest.insuresmart.com.cn; access_log /var/log/nginx/standardtest_access.log;
error_log /var/log/nginx/standardtest_error.log;
root html;
index index.html index.htm index.php; location / {
proxy_pass http://standardprod; proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 64k;
proxy_buffers 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
} }

在配置文件nginx.conf添加

 upstream standardprod
{
server 172.16.120.193:;
}

此端口对应前端布置的nginx设置监听的端口

yum install -y unzip zip

上一篇:HTTP Cookie/Session


下一篇:iis7.5 设置伪静态