server { listen 80; listen [::]:80; server_name homework.jackyu.cn; # rewrite ^(.*)$ https://$host$1 permanent; return 307 https://$server_name$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name homework.jackyu.cn; ssl_certificate /etc/nginx/ssl/jackyu.cn/alpha/jackyu.cn_server_cert.pem; ssl_certificate_key /etc/nginx/ssl/jackyu.cn/alpha/jackyu.cn_key.pem; root /var/www/homework/frontend; # Add index.php to the list if you are using PHP index index.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. index index.html; try_files $uri $uri/ /index.html; } location /student { index manage.html; try_files $uri $uri/ /student.html; } location /teacher { index manage.html; try_files $uri $uri/ /teacher.html; } location /admin { index admin.html; try_files $uri $uri/ /admin.html; } location ^~/upload/ { alias /var/www/homework/api/upload/; } include error_json; location /api/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_pass http://127.0.0.1:9008/; 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; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1000m; } location /zigbee-pi { alias /var/www/zigbee-pi/frontend/; index index.html; } location /zigbee-pi/api/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_pass http://127.0.0.1:9200/; 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; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 1000m; } }