123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- # server {
- # server_name _;
- # server_tokens off;
- # #large_client_header_buffers 4 32k;
- # client_max_body_size 50M;
- # charset utf-8;
- # index index.html;
- # # 启动SSL及证书匹配 ######################################################
- # listen 443 ssl default_server; # managed by Certbot
-
- # # ssl_certificate /etc/letsencrypt/live/edutextbook/fullchain.pem; # managed by Certbot
- # # ssl_certificate_key /etc/letsencrypt/live/edutextbook/privkey.pem; # managed by Certbot
- # # include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
- # # ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
- # # 启用OCSP stapling ######################################################
- # ssl_stapling on;
- # ssl_stapling_verify on;
- # # valid表示缓存5分钟
- # resolver 8.8.8.8 8.8.4.4 valid=300s;
- # # 网络超时时间
- # resolver_timeout 5s;
- # # 启动Gzip Json模式 ######################################################
- # gzip_http_version 1.0; # gzip支持http协议 proxy 必须用
- # gzip on;
- # gzip_vary on;
- # gzip_proxied any;
- # gzip_static on;
- # gzip_comp_level 4;
- # gzip_min_length 256;
- # gzip_buffers 4 8k;
- # gzip_types text/html text/plain application/javascript application/x-javascript text/css application/xml application/json;
- # location /api {
- # if ($request_method = 'OPTIONS') {
- # add_header 'Access-Control-Allow-Origin' '*';
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- # #
- # # Custom headers and headers various browsers *should* be OK with but aren't
- # #
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- # #
- # # Tell client that this pre-flight info is valid for 20 days
- # #
- # add_header 'Access-Control-Max-Age' 1728000;
- # add_header 'Content-Type' 'text/plain; charset=utf-8';
- # add_header 'Content-Length' 0;
- # return 204;
- # }
- # if ($request_method = 'POST') {
- # add_header 'Access-Control-Allow-Origin' '*' always;
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- # add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- # }
- # if ($request_method = 'GET') {
- # add_header 'Access-Control-Allow-Origin' '*' always;
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- # add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- # }
- # rewrite ^/(.*)$ /$1 break;
- # proxy_pass http://127.0.0.1:61337/api;
- # }
- # location /parse {
- # if ($request_method = 'OPTIONS') {
- # add_header 'Access-Control-Allow-Origin' '*';
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- # #
- # # Custom headers and headers various browsers *should* be OK with but aren't
- # #
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- # #
- # # Tell client that this pre-flight info is valid for 20 days
- # #
- # add_header 'Access-Control-Max-Age' 1728000;
- # add_header 'Content-Type' 'text/plain; charset=utf-8';
- # add_header 'Content-Length' 0;
- # return 204;
- # }
- # if ($request_method = 'POST') {
- # add_header 'Access-Control-Allow-Origin' '*' always;
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- # add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- # }
- # if ($request_method = 'GET') {
- # add_header 'Access-Control-Allow-Origin' '*' always;
- # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- # add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- # }
- # rewrite ^/(.*)$ /$1 break;
- # proxy_pass http://127.0.0.1:61337/parse;
- # }
- # location /{
- # proxy_set_header Host $http_host;
- # proxy_set_header X-Real-IP $remote_addr;
- # proxy_set_header X-Scheme $scheme;
- # proxy_set_header X-Forwarded-Proto $scheme;
- # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- # proxy_pass http://127.0.0.1:61337/;
- # proxy_redirect off;
- # }
- # }
- server {
- listen 80 default_server;
- server_name _;
- # 启动Gzip Json模式 ######################################################
- gzip_http_version 1.0; # gzip支持http协议 proxy 必须用
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- gzip_static on;
- gzip_comp_level 4;
- gzip_min_length 256;
- gzip_buffers 4 8k;
- gzip_types text/html text/plain application/javascript application/x-javascript text/css application/xml application/json;
-
- location /api {
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain; charset=utf-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'POST') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*' always;
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Access-Control-Allow-Origin' always;
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
- }
- rewrite ^/(.*)$ /$1 break;
- proxy_pass http://127.0.0.1:61337/api;
- }
- location /parse/{
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Scheme $scheme;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_pass http://127.0.0.1:61337/parse/;
- proxy_redirect off;
- }
- root /var/www/edu-textbook/;
- location /{
- try_files $uri $uri/ /index.html?$query_string;
- }
- }
|