这是我访问的配置
https://www.example.com.
末尾的点不起作用
# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/example.sock; # for a file socket
}
# Redirect
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/example.key;
rewrite ^(.*) $scheme://www.example.com$1 permanent;
}
# SSL Request
server {
listen 443;
server_name www.example.com;
root /var/www/example;
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
ssl on;
ssl_certificate /etc/nginx/ssl/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/example.key;
ssl_protocols TLSv1.2 TLSv1.1;
# Django media
location /uploads {
alias /var/www/example/uploads; # your Django project's media files - amend as required
expires 7d;
}
location /static {
alias /var/www/example/static; # your Django project's static files - amend as required
expires 7d;
}
location /favicon.ico {
alias /var/www/example/static/img/favicon.ico; # your Django project's static files - amend as required
}
location /robots.txt {
alias /var/www/example/robots.txt; # robots.txt
}
location /ntat {
uwsgi_pass django;
include uwsgi_params;
}
location / {
rewrite ^(.*) http//www.example.com$1;
}
}
# Normal Request
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name www.example.com
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /ntat {
rewrite ^(.*) https://www.example.com$1;
}
# Django media
location /uploads {
alias /var/www/example/uploads; # your Django project's media files - amend as required
expires 7d;
}
location /ntat {
rewrite ^(.*) https://www.example.com$1;
}
# Django media
location /uploads {
alias /var/www/exam/uploads; # your Django project's media files - amend as required
expires 7d;
}
location /static {
alias /var/www/example/static; # your Django project's static files - amend as required
expires 7d;
}
location /favicon.ico {
alias /var/www/example/static/img/favicon.ico; # your Django project's static files - amend as required
}
location /robots.txt {
alias /var/www/example/robots.txt; # robots.txt
}
location /timepass {
alias /var/www/timepass; # Snake Game
}
# Finally, send all non-media requests to the Django server.
location / {
rewrite ^(.*) https://www.example.com$1;
uwsgi_pass django;
include uwsgi_params;
uwsgi_read_timeout 180;
}
}
答案 0 :(得分:0)
default_server
rewrite
。 return
以确保server_name
之间没有不同的优先级server
(缺少http//www.example.com$1;
) :
比www.example.com.
多different server name for NGINX,但是您没有www.example.com
专门监听点分域,因此最好使用默认服务器标记server
块,以确保正确匹配。
server