对我的Web服务器进行故障排除。“页面不正确重定向”。

发布于 2025-02-06 10:50:38 字数 1648 浏览 1 评论 0原文

在某些上下文中,我正在使用nodejs并为我的Web服务器表示Express,我正在使用NGINX,但由于某种原因而失败了,我试图在上一篇文章中获得帮助,但没有任何帮助。

当我连接到网站HTTP工作正常时,HTTPS获取“该页面无法正确重定向”。当我直接使用IT IP连接到我的网站时,它具有HTTPS(忽略了它仍然没有真正信任的事实,因为我的证书已链接到我的域),我只是想弄清楚它的位置。

const express = require('express');
const https = require("https");
const http = require("http")
const fs = require('fs')
const bodyParser = require('body-parser');
var cookieParser = require('cookie-parser')
const login = require("../modules/login")
const app = express(); 
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser())
app.set('view engine', 'ejs');
app.set('views', '../public/views');
app.use( express.static( "public" ) );

http.createServer(function (req, res) {
    res.writeHead(307, { "Location": "https://www.ppealliance.com"});
    res.end();
}).listen(80);

https
  .createServer(
    {
      key: fs.readFileSync('Path to Letsencrypt Certificate'),
      cert: fs.readFileSync('Path to Letsencrypt Certificate'),
    },
    app
  )
  .listen(443, () => {
    console.log(https.request)
  })

app.get('/', (req, res) => {
    login.redirect(req, res)
});

app.get('/admin-login', (req, res, next) => {
    res.render('admin-login', { title:'Admin login'});
}); 

app.post('/admin-login-cookies', (req, res) => {
    login.cookiecheck(req, res)
});

app.get('/signup-1', (req, res) => {
    res.render('signup-1', { title:'Signup Part One'});
});


app.post('/admin-login', (req, res) => {
    login.login(req,res)
});

app.get('/home', (req, res) => {
    login.redirect(req, res)
});

Some context, I'm using Nodejs and Express for my Web Server, I was using nginx but it failed for some reason and I tried to get help in a previous post but nothing.

When I connect to my site http works fine, https gets "The page isn't redirecting properly". When I connect to my site directly with it's IP it has https (ignoring the fact that it's still isn't really trusted since my certificates are linked to my domain) I just am trying to figure out where it's going wrong.

const express = require('express');
const https = require("https");
const http = require("http")
const fs = require('fs')
const bodyParser = require('body-parser');
var cookieParser = require('cookie-parser')
const login = require("../modules/login")
const app = express(); 
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser())
app.set('view engine', 'ejs');
app.set('views', '../public/views');
app.use( express.static( "public" ) );

http.createServer(function (req, res) {
    res.writeHead(307, { "Location": "https://www.ppealliance.com"});
    res.end();
}).listen(80);

https
  .createServer(
    {
      key: fs.readFileSync('Path to Letsencrypt Certificate'),
      cert: fs.readFileSync('Path to Letsencrypt Certificate'),
    },
    app
  )
  .listen(443, () => {
    console.log(https.request)
  })

app.get('/', (req, res) => {
    login.redirect(req, res)
});

app.get('/admin-login', (req, res, next) => {
    res.render('admin-login', { title:'Admin login'});
}); 

app.post('/admin-login-cookies', (req, res) => {
    login.cookiecheck(req, res)
});

app.get('/signup-1', (req, res) => {
    res.render('signup-1', { title:'Signup Part One'});
});


app.post('/admin-login', (req, res) => {
    login.login(req,res)
});

app.get('/home', (req, res) => {
    login.redirect(req, res)
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文