nginx.conf
user www;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
aaa.conf 第一个 网站 aaa.top 不带 www
server {
listen 80;
server_name aaa.top;
return 301 https://$server_name$request_uri;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_pass http://127.0.0.1:8000;
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;
}
location /static { # 静态文件
alias /home/www/p/z/app/static;
}
}
server {
listen 443 ssl;
server_name aaa.top;
location / {
proxy_pass http://127.0.0.1:8000;
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;
proxy_cookie_path / "/;SameSite=none; HTTPOnly; Secure";
}
location /static { # 静态文件
alias /home/www/p/z/app/static;
}
}
b.aaa.top 第二个网站
server {
listen 80;
server_name b.aaa.top;
return 301 https://$server_name$request_uri;
access_log /var/log/nginx/access_note.log;
error_log /var/log/nginx/error_note.log;
location / {
proxy_pass http://127.0.0.1:8800;
proxy_redirect off;
}
location /static { # 静态文件
alias /home/www/p/n/app/static;
}
}
server {
listen 443 ssl;
server_name nt.vscs.top;
location / {
proxy_pass http://127.0.0.1:8800;
}
location /static { # 静态文件
alias /home/www/p/n/app/static;
}
}
访问 b.aaa.top 不正常,访问到的程序是 8000 端口的 没有到 8800
不知道为啥来
你不是自己写的return 301 xx.top了