Nginx 설정 은 전단 루트 와 백 엔 드 루트 의 분 리 를 실현 합 니 다
9806 단어 인터넷 구조
start nginx.exe
정지: Nginx 루트 디 렉 터 리 에서 cmd 콘 솔 nginx -s stop
다시 시작: Nginx 루트 디 렉 터 리 에서 cmd 콘 솔 nginx -s reload
메모: Nginx. conf 파일 을 수정 할 때마다 Nginx 서 비 스 를 다시 시작 해 야 합 니 다.다음은 앞 뒤 엔 드 경로 가 분 리 된 nginx. conf 의 설정 입 니 다. 파일 경로: nginx 설치 디 렉 터 리 / conf / nginx. conf 각 설정 항목 의 역할 과 설정 설명 이 설정 에 설명 되 어 있 습 니 다.
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
upstream ota_server { #
server 127.0.0.1:8088 weight=5;# weight , , 。
}
server {
#
listen 80;
#
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# Nginx #
# , permanent,last http://blog.csdn.net/zhanlanmg/article/details/49684803
#rewrite , URL, ( “()” ) $1 $2
# rewrite ^/([a-z]*)/([0-9])/(.*)$ /param-$1/value-$2/$3 /age/13/zhangsan url /param-age/value-13/zhangsan
rewrite ^/(.*)/$ /$1 permanent;
# index.html
index index.html;
# nginx html umsapp-ota
root html/umsapp-ota;
# , localhost , :nginx /html/umsapp-ota/index.html
# , ajax /api, /api
location /api {
#rewrite break - url , , location , , url http://blog.csdn.net/zhanlanmg/article/details/49684803
# ota api, api , , url
# tomcat , 。
# tomcat web webapp 2 A_Server,B_Server, B_Server, rewrite ^/api/(.*)$ /B_Server/$1 break;
rewrite ^/api/(.*)$ /$1 break;
# ,ota_server upstream
proxy_pass http://ota_server;
# , OTA-WEB “APP ” , http://localhost/#/app/list/1
# js ajax /api/api-group/list?start=0&limit=10&page=1
#( :http://localhost/api/api-group/list?start=0&limit=10&page=1),
# ajax http://ota_server/api-group/list?start=0&limit=10&page=1, (rewrite break )
# 。
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;
}
######################################################################################################################################################
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}