admin管理员组文章数量:1123869
I'm Alessio, and I'm facing an issue with the Nginx reverse proxy.
Here is the configuration file for the redirects:
# Nextcloud server configuration
server {
listen 80;
server_name nextcloud.example www.nextcloud.example;
# Redirect from HTTP to HTTPS
return 301 https://$host$request_uri;
}
# HTTPS traffic configuration (port 443)
server {
listen 443 ssl;
server_name nextcloud.example www.nextcloud.example;
ssl_certificate /etc/nginx/sites-available/Cert/NextCloud/fullchain.pem;
ssl_certificate_key /etc/nginx/sites-available/Cert/NextCloud/privkey.pem;
# Reverse proxy configuration
location / {
proxy_pass https://192.168.1.65:443;
proxy_set_header Host $host; # Pass the original 'Host' header to the backend
proxy_set_header X-Real-IP $remote_addr; # Pass the client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Pass the previous IPs
proxy_set_header X-Forwarded-Proto $scheme; # Pass the protocol (http/https)
proxy_cache_bypass $http_upgrade; # Avoid cache for WebSocket or upgrade
}
}
# HTTP traffic configuration (port 80)
server {
listen 80;
server_name passwordmanager.example www.passwordmanager.example;
# Redirect from HTTP to HTTPS
return 301 https://$host$request_uri;
}
# HTTPS traffic configuration (port 443)
server {
listen 443 ssl;
server_name passwordmanager.example www.passwordmanager.example;
ssl_certificate /etc/nginx/sites-available/Cert/PasswordManager/fullchain.pem;
ssl_certificate_key /etc/nginx/sites-available/Cert/PasswordManager/privkey.pem;
# Reverse proxy configuration
location / {
proxy_pass https://192.168.1.8:443;
proxy_set_header Host $host; # Pass the original 'Host' header to the backend
proxy_set_header X-Real-IP $remote_addr; # Pass the client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Pass the previous IPs
proxy_set_header X-Forwarded-Proto $scheme; # Pass the protocol (http/https)
proxy_cache_bypass $http_upgrade; # Avoid cache for WebSocket or upgrade
}
}
This works perfectly within my local network, but when I try to connect from the internet, I get redirected from
nextcloud.example
to
passwordmanager.example
.
Has anyone experienced something similar or have suggestions on how to resolve this?
I tried placing the Reverse Proxy in the DMZ, but there was no change.
I also attempted to separate the code into two files, but still, nothing changed.
I'm Alessio, and I'm facing an issue with the Nginx reverse proxy.
Here is the configuration file for the redirects:
# Nextcloud server configuration
server {
listen 80;
server_name nextcloud.example.com www.nextcloud.example.com;
# Redirect from HTTP to HTTPS
return 301 https://$host$request_uri;
}
# HTTPS traffic configuration (port 443)
server {
listen 443 ssl;
server_name nextcloud.example.com www.nextcloud.example.com;
ssl_certificate /etc/nginx/sites-available/Cert/NextCloud/fullchain.pem;
ssl_certificate_key /etc/nginx/sites-available/Cert/NextCloud/privkey.pem;
# Reverse proxy configuration
location / {
proxy_pass https://192.168.1.65:443;
proxy_set_header Host $host; # Pass the original 'Host' header to the backend
proxy_set_header X-Real-IP $remote_addr; # Pass the client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Pass the previous IPs
proxy_set_header X-Forwarded-Proto $scheme; # Pass the protocol (http/https)
proxy_cache_bypass $http_upgrade; # Avoid cache for WebSocket or upgrade
}
}
# HTTP traffic configuration (port 80)
server {
listen 80;
server_name passwordmanager.example.com www.passwordmanager.example.com;
# Redirect from HTTP to HTTPS
return 301 https://$host$request_uri;
}
# HTTPS traffic configuration (port 443)
server {
listen 443 ssl;
server_name passwordmanager.example.com www.passwordmanager.example.com;
ssl_certificate /etc/nginx/sites-available/Cert/PasswordManager/fullchain.pem;
ssl_certificate_key /etc/nginx/sites-available/Cert/PasswordManager/privkey.pem;
# Reverse proxy configuration
location / {
proxy_pass https://192.168.1.8:443;
proxy_set_header Host $host; # Pass the original 'Host' header to the backend
proxy_set_header X-Real-IP $remote_addr; # Pass the client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Pass the previous IPs
proxy_set_header X-Forwarded-Proto $scheme; # Pass the protocol (http/https)
proxy_cache_bypass $http_upgrade; # Avoid cache for WebSocket or upgrade
}
}
This works perfectly within my local network, but when I try to connect from the internet, I get redirected from
nextcloud.example.com
to
passwordmanager.example.com
.
Has anyone experienced something similar or have suggestions on how to resolve this?
I tried placing the Reverse Proxy in the DMZ, but there was no change.
I also attempted to separate the code into two files, but still, nothing changed.
Share Improve this question asked yesterday Alessio RestainoAlessio Restaino 1 New contributor Alessio Restaino is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0RESOLVED; Everything was correct; the issue was with the port configuration on the router. I had entered the wrong MAC address for the reverse proxy and was directly pointing to the server. That’s why I could only access it.
本文标签:
版权声明:本文标题:Reverse Proxy Nginx work inside my network, but from internet redirect to only one Server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736594281a1945124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论