目的
解决跨域问题
下载
http://nginx.org/en/download.html
普通配置 nginx>conf>nginx.conf
#user nobody;
worker_processes 1;
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 localhost {
#根据ip计算将请求分配各那个后端tomcat,许多人误认为可以解决session问题,其实并不能。
#同一机器在多网情况下,路由切换,ip可能不同
#ip_hash;
server localhost:18081;
server localhost:18080;
}
server {
listen 80;
server_name localhost;
#页面根路径
location / {
root F:\superbuy\Orion\static;
index index.html index.htm;
}
#接口反向代理 登录接口
location /api/site/ {
rewrite ^.+api/site/?(.*)$ /api/site/$1 break;
include uwsgi_params;
proxy_pass http://login.super.com;
}
#接口反向代理 其他接口
location /api/ {
rewrite ^.+api/?(.*)$ /api/$1 break;
include uwsgi_params;
proxy_pass http://www.super.com;
}
error_page 404 = /index.html;
location = /50x.html {
root html;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 8004;
server_name somename alias another.alias;
location / {
root F:\superbuy\Orion\static;
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;
# }
#}
}