💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
正确写法 ``` server { # listen 80; listen 443 ssl; server_name tuan.nineopen.com; ssl_certificate /etc/nginx/ssl/tuan.nineopen.com-ca-bundle.crt; ssl_certificate_key /etc/nginx/ssl/tuan.nineopen.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; root /home/web/tuan; index index.html index.htm; 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://122.114.186.38:81; } location /sends { 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://122.114.186.38:82; } location /send { try_files $uri $uri/ /send/index.html; } location /shops { 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://122.114.186.38:83; } location /shop { try_files $uri $uri/ /shop/index.html; } location /colonels { 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://122.114.186.38:84; } location /colonel { try_files $uri $uri/ /colonel/index.html; } } ``` ``` server { listen 81; server_name 122.114.186.38; location / { root /home/web/tuan/home; } } server { listen 82; server_name 122.114.186.38; location / { root /home/web/tuan/send; } } server { listen 83; server_name 122.114.186.38; location / { root /home/web/tuan/shop; } } server { listen 84; server_name 122.114.186.38; location / { root /home/web/tuan/colonel; } } ``` 1.第一种错误 ``` server { listen 80; server_name shop.nineopen.com; 必须是ip地址 location / { root /home/web/tuan/colonel; } } ``` 2.第二种错误 ``` 如果没有 location /colonel { try_files $uri $uri/ /colonel/index.html; } 则 location /colonels { 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://122.114.186.38:84; } 会404 需要将 http://122.114.186.38:84改为http://122.114.186.38:84/index.html,但不能加载css和js; 如果有 try_files设置则改为http://122.114.186.38:84,此时能正常加载css和js; ``` 3.第三种错误 ``` location /colonel { try_files $uri $uri/ /colonel/index.html; } 与 location /colonels { 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://122.114.186.38:84; } 不能重名,一个/colonel,一个/colonels; ```