命令:
启动:start nginx
检查配置是否正确:nginx -t
修改配置后重载:nginx -s reload
关闭:nginx -s stop
nginx+tomcat整合
配置文件 nginx.conf里
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
修改为:
server {
listen 80;
server_name localhost:8080;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:8080;
}
但是访问tomcat响应很慢,修改为:
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1000m;
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 60;
}