Open JiashuGuo opened 5 years ago
You need to be running two servers for that, because HTTP and HTTPS use different ServerSocket implementations, so they need to be on different ports (80 & 443 are the defaults).
This being done, you can simply have the HTTP server redirect everyone (using HTTP 3XX with Location
headers) to the same path in the HTTPS server and you're set.
You need to be running two servers for that, because HTTP and HTTPS use different ServerSocket implementations, so they need to be on different ports (80 & 443 are the defaults).
This being done, you can simply have the HTTP server redirect everyone (using HTTP 3XX with
Location
headers) to the same path in the HTTPS server and you're set.
Thank you so much for the idea, I am trying with this in the App.
You need to be running two servers for that, because HTTP and HTTPS use different ServerSocket implementations, so they need to be on different ports (80 & 443 are the defaults).
This being done, you can simply have the HTTP server redirect everyone (using HTTP 3XX with
Location
headers) to the same path in the HTTPS server and you're set.
I tried to run with two server, the redirecting works well, but can't on default port, I have add redirect in IP table still seems doesn't work. Do you have any idea about running server under port 1024 in Linux?
Are you running the application as root? By default, processes need root privileges to bind to ports 1-1024 on Linux.
No, we don’t run it on as root for security consider, so I am looking for other solution like redirect in ip table.
On Tue, Apr 9, 2019 at 2:33 PM Noah Andrews notifications@github.com wrote:
Are you running the application as root? By default, processes need root privileges to bind to ports 1-1024 on Linux.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NanoHttpd/nanohttpd/issues/538#issuecomment-481448856, or mute the thread https://github.com/notifications/unsubscribe-auth/AX-gazslpYuuxHgclfBpoGX_0wZCAGZLks5vfQc5gaJpZM4cZXIR .
The iptable redirecting works after I reboot the device.
On Tue, Apr 9, 2019 at 2:35 PM Jiashu Guo jiashuguo@email.arizona.edu wrote:
No, we don’t run it on as root for security consider, so I am looking for other solution like redirect in ip table.
On Tue, Apr 9, 2019 at 2:33 PM Noah Andrews notifications@github.com wrote:
Are you running the application as root? By default, processes need root privileges to bind to ports 1-1024 on Linux.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NanoHttpd/nanohttpd/issues/538#issuecomment-481448856, or mute the thread https://github.com/notifications/unsubscribe-auth/AX-gazslpYuuxHgclfBpoGX_0wZCAGZLks5vfQc5gaJpZM4cZXIR .
Either use ports above 1024 or sudo
. You don't really have other choices.
Hi there, I am trying to automatically correct/add https at the beginning of the URL the user typed in, for example: no matter user type http://XXXX or just XXXX I would like to change it to https://XXXX.
Does any one know if nanohttpd support redirecting from http request to https? I have viewed lots of answer online and most of them related to use ./htaccess in Apache server, I am afraid Nanohttpd does't support that method.
Thanks for any discussion!