Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No HTTPS for CV4PVE-ADMIN #67

Open
kenrmayfield opened this issue Jun 30, 2023 · 24 comments
Open

No HTTPS for CV4PVE-ADMIN #67

kenrmayfield opened this issue Jun 30, 2023 · 24 comments
Labels
enhancement New feature or request

Comments

@kenrmayfield
Copy link

The URL for CV4PVE-ADMIN can only be HTTP? HTTPS will not work. I can not use
CV4PVE-ADMIN in a Live Business Environment if only HTTP is used to reach the URL for CV4PVE-ADMIN.

There also No Option to Turn OFF HTTP and Turn ON HTTPS or just use HTTPS completely.

When you try the URL with HTTPS, you will Receive the Error:
Secure Connection Failed
An error occurred during a connection to 192.168.1.143:5000. SSL received a record that exceeded the maximum permissible length.
Error code: SSL_ERROR_RX_RECORD_TOO_LONG
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.
Learn more…

I did also try Editing the the File appsettings.json and change "urls": "http://0.0.0.0:5000", to "urls": "https://0.0.0.0:5000",
however the Page will not come up.

This is a Great Tool however I can not use this in the Live Business Environment with the URL being HTTP due to the fact that anyone could SNIFF the Username and Password to the Tool since HTTP is Non Encrypted.

Thanks,
Kenneth

@franklupo
Copy link
Member

hi,
thank you for your interest. Let's check how to resolve your request.

best reagrds

@kenrmayfield
Copy link
Author

Frank,

I am doing a Follow Up?

Thanks,
Kenneth

@franklupo
Copy link
Member

Sorry, I don't understand. What do you mean?

@kenrmayfield
Copy link
Author

I was Referring to the Request that I made about HTTPS when I started this Post 5 Days Ago.

@matteocv
Copy link
Contributor

matteocv commented Jul 6, 2023

Hello @kenrmayfield,
our development team is working on it, we will update you in this issue.

Best Regards,

@kenrmayfield
Copy link
Author

kenrmayfield commented Jul 6, 2023

I was wondering if Creating a NGINX SSL for Docker would Work?
I wanted to see what you think?
I was wondering if there is something in the Code I Manipulated below is missing something or it will not work?

I have Manipulated the Code Below with Steps:

Step 1: Create Directory

Create a directory with the name "docker_ssl_proxy" to store the NGINX Configuration file and the certificate and key

$ mkdir docker_ssl_proxy

Step 2: Change Directory to docker_ssl_proxy
NOTE:
You must be under this directory before executing the following steps (Commands).

Step 2.a: Use Signed Certificates
NOTE:
If you have Certificates you can simply copy the following 2 files to the Current Directory
key.pem
cert.pem

Step 2.b Create the Self-Signed Certificates (If needed)

Use OpenSSL to create a Self-Signed Certificate, following command will create a Self-Signed Certificate and a Private Key with a Validity of 365 days.

$ openssl req -subj '/CN=localhost' -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365

Step 3: Find your container IP address
3.1: Find your Container ID.

$ docker ps
NOTE:
It will list all the processes that are running and find out your Container Id.

3.2 Find IP Address

To find the container IP address from the Host, you can run the command
NOTE:
(Container-ID): replace this with the value that you get from Step 3.1

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' (Contrainer-ID)

NOTE:
The response of the above command will be an IP address

Step 4: Create the NGINX configuration file

In the same directory (docker_ssl_proxy), create a Configuration File that will Proxy All the Traffic to your upstream server. The upstream server is the application server running a non-SSL connection. The SSL will be using NGINX, and all the traffic will be Proxied to the Host (using the IP Address that you got in Step 3.2)

The Configuration File, which in this example is called "proxy_ssl.conf," but can have any name as long as it ends in .conf.
Example file: proxy_ssl.conf
NOTE: 5000 is the Port for CV4PVE-ADMIN.
The only thing you need to replace in this file is the Container IP Address.
This file simply instructs NginX to listen, with SSL and the correct Certs and Keys, on port 443 and to proxy all the requests to the Host on port 5000.

The File must have the following Contents below:

server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/conf.d/cert.pem;
ssl_certificate_key /etc/nginx/conf.d/key.pem;
location / {
proxy_pass http://(Container IP):5000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}

NOTE:
This file simply instructs NginX to listen, with SSL and the correct Certs and Keys, on port 443 and to Proxy All the Requests to the Host on port 5000

Step 5: Run the Docker Container

At this point, we have all the Configuration in place to Proxy the Traffic; we simply need to run the Docker Container with the following command.

$ docker run --name nginx_proxy -d -v pwd:/etc/nginx/conf.d -p 443:443 nginx

NOTE: 5000 is the Port for CV4PVE-ADMIN
If you face issues, try to replace PWD in the command above with the Full Directory Path for "docker_ssl_proxy", where you have Config and Cert files.

$docker run --name nginx_proxy -d -v (yourdirectory):/etc/nginx/conf.d -p 443:443 nginx

@franklupo
Copy link
Member

you could use a docker compose

@kenrmayfield
Copy link
Author

kenrmayfield commented Jul 8, 2023

@matteocv
Frank,

On my Previous Posting........what did you think about the Code to try to get HTTPS to work?

As far as Docker Compose...........It will be the same Problem.........still No HTTPS. Even if you use a Container, that does not change the Protocol.

@franklupo
Copy link
Member

hi,
I didn't enable Forwarded. In the next release we will come up with an example for Nginx

best reagrds

@matteocv matteocv added the enhancement New feature or request label Jul 19, 2023
@franklupo
Copy link
Member

@kenrmayfield
Copy link
Author

@matteocv

Frank,

I Sent you and Matteo a Email asking a Question about the Reverse Proxy.

@kenrmayfield
Copy link
Author

@matteocv

Frank,

I was checking back on Previous Comment.

@kenrmayfield
Copy link
Author

@matteocv

Frank,

Sent Response Email.

@kenrmayfield
Copy link
Author

@matteocv

Frank,

Sent Response Email. Checking back with you Guys.

@franklupo
Copy link
Member

Hi,
if you want attach the docker code for HTTPS.

best regards

@franklupo
Copy link
Member

News?

@kenrmayfield
Copy link
Author

@franklupo
@matteocv

Still having a Problem getting HTTPS to work?

I tried: https://github.com/Corsinvest/cv4pve-admin/tree/main/src/Docker/Nginx/ReverseProxy

@kenrmayfield
Copy link
Author

@franklupo
@matteocv

Still having a Problem getting HTTPS to work?

I tried: https://github.com/Corsinvest/cv4pve-admin/tree/main/src/Docker/Nginx/ReverseProxy

@Aterfax
Copy link

Aterfax commented Oct 24, 2023

@franklupo @matteocv

Still having a Problem getting HTTPS to work?

I tried: https://github.com/Corsinvest/cv4pve-admin/tree/main/src/Docker/Nginx/ReverseProxy

Set up a SWAG reverse proxy, HTTPS over port 5000. SSL all setup fine. Errors suggest the backend docker for CV4PVE seems to be incompatible with running in HTTPS in some manner.

Seeing in browser console:

Uncaught (in promise) WebSocket is not in the OPEN state

[2023-10-24T17:50:53.720Z] Error: System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.<>c__DisplayClass13_0.<<NavigateToCore>g__PerformNavigationAsync|0>d.MoveNext()

Seeing in docker logs:

[ERR] Navigation failed when changing the location to /login?key=d3f0d667-c2c7-4e7e-8676-REDACTED

@franklupo
Copy link
Member

I found and fixed the problem for reverse proxy.

franklupo added a commit to franklupo/cv4pve-admin that referenced this issue Apr 2, 2024
franklupo added a commit that referenced this issue Apr 2, 2024
@Bradley-Radomski
Copy link

How can HTTPS be added to a Windows hosted instance?

@franklupo
Copy link
Member

@Bradley-Radomski
Copy link

While I appreciate the response, I was just curious if there was an option for using the Windows.exe application. We are not running it in Docker therefore cannot put it behind nginx 'easily'. Was just curious if there was a toggle that can be added to force HTTPS

@franklupo
Copy link
Member

for now it is not our priority, but it is in the things to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants