要疯了,求大佬路过帮个忙, nginx 配置的问题,点击网页内链接跳转少了一些字符

查看 34|回复 0
作者:maxwell29   
最近折腾博客,打算部署在我自己搭建的 ubuntu 主机上。主机上面已经搭建了一些服务,比如 webmin ,nextcloud ,也配置了 ssl 。我的主机 443 端口监听的是 nextcloud 的服务,location / {}那块交给了 nextcloud ,我尝试着在 / 后面增加自定义字符,但是跳转老是出错,于是就只有算了( nextcloud 是用 docker 搭建的)。
我用 hugo 生成的静态博客,起初是放在 https 的 server 中的,但是跑起来后是中缺少 css 和图片,后来用了下面这段代码:
location ~* \.(gif|jpg|jpeg|png|css|js|ico|css|eot|svg|ttf|woff|mov)$ {
root /home/myblog/public/;
expires 48h;
access_log off;
}

大概意思是要加载 css 吧,显示正常,访问首页 https://XXXX.XXXX/blog/没问题,但是每次点击页面内的链接,比如 post ,就会跳转到 https://XXXX.XXXX/post 。我的 https://XXXX.XXXX/是我的 nextcloud 主页,于是在这里就冲突了。搞的我很苦恼,而且上面那段代码导致我其它放在 443 端口里面的服务全都加载不出来图片。
我换了下思路,打算把博客部署到 http 的 80 端口,然后用 https 的 443 转到 http 的 80 ,下面是我的配置文件。但是依然有上面那个问题,即点击页面连接,不会在 https://XXXX.XXXX/加个 blog/。还是会跟我的 nextcloud 产生冲突。
我不知道我有没有表述清楚我的问题。
我是一个计算机爱好者,我只是自己在摸索这些问题,对于 nginx 缺乏系统性学习,爬了一些帖子,发现真的很头大。已经三个晚上了,我查了很多资料,发现我搞不定这个问题,有些撑不住了。
下面是我的 /etc/nginx/nginx.conf 配置文件内容:
---
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name XXXX.XXXX;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/myblog/public/;
index index.html index.htm;
autoindex on;
}
location ~* \.(gif|jpg|jpeg|png|css|js|ico|css|eot|svg|ttf|woff|mov)$ {
root /home/myblog/public/;
expires 48h;
access_log off;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root html;
# }
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
server {
listen [::]:80;
listen [::]:443 ssl;
server_name XXXX.XXXX;
ssl_certificate /etc/conf/cert.pem;
ssl_certificate_key /etc/cert.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:XXXX;
proxy_set_header Host $host:$server_port;
client_max_body_size 4096m;
}
location /qqq/ {
proxy_pass http://127.0.0.1:XXXXX/; # 根据你的 IP 地址和端口号修改
proxy_http_version 1.1;

proxy_set_header Host 127.0.0.1:XXXX; # 根据你的 IP 地址和端口号修改
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;

# 以下参数不适用于 qBittorrent !请务必移除(若有)
#proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header X-Real-IP $remote_addr;

# 可选,设置后可一次性添加 100M 的种子
client_max_body_size 100M;

# 从 4.2.2 版本起,若你在 qBittorrent 内部设置了 HTTPS ,则不需要设置以下参数。否则,必须设置以下参数用以保证 Cookie 的安全性
proxy_cookie_path / "/; Secure";       
}       
location /web11/ {
proxy_pass https://127.0.0.1:XXXX/;
client_max_body_size 4096m;
}
location /nt1/ {
proxy_pass http://127.0.0.1:XXXX/;
client_max_body_size 4096m;
}
location /ViP/ {
proxy_pass http://127.0.0.1:XXXX/ViewPower/;
}
location /docker/ {
proxy_pass http://127.0.0.1:XXXX/;
}
location /ho/ {
proxy_pass http://127.0.0.1:XXXX/;
proxy_cache_key $host$uri$is_args$args;
proxy_set_header Host $host:$server_port;
}
location /ca/ {
proxy_pass http://127.0.0.1:XXXX/;
client_max_body_size 4096m;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /calibre; # IMPORTANT: path has NO trailing slash
}
# location /public/ {
# include /etc/nginx/mime.types;
# default_type application/octet-stream;
# root /home/myblog/;
#
# index index.html index.htm;
# autoindex on;
# }

location /blog/ {
proxy_pass http://127.0.0.1:80/;
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;
}
}
XXXX 是我隐藏了的内容。先行谢过!
您需要登录后才可以回帖 登录 | 立即注册

返回顶部