| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #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;
- sendfile on;
- keepalive_timeout 65;
- server {
- listen 80;
- server_name localhost;
- location / {
- root html/dist;
- index index.html;
- }
- }
- server {
- listen 9001;
- server_name localhost;
- #接口代理, 用于解决跨域问题
- location /ws/ {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' '*';
- add_header 'Access-Control-Allow-Headers' '*';
- proxy_pass http://localhost:9002/;
- #代理到上面的地址去
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "Upgrade";
- }
- }
- server {
- listen 9091 ;
- server_name localhost;
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS,PUT';
- add_header 'Access-Control-Allow-Headers' '*';
- if ($request_method = 'OPTIONS') {
- return 204;
- }
- location / {
- 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_pass http://localhost:9100/;
- client_max_body_size 1024m;
- }
- }
- }
|