简体   繁体   中英

How can I set an SSL certificate with React on cPanel Server?

I'm a newbie on React.js.

I'm trying to deploy a React.js website to a cPanel Server which doesn't have Node.js support. So I'm using these steps:

  1. npm run-script build
  2. Move build folder content to server's public_html via git-ftp

CPanel has free SSL. I've used it so much times with PHP.

I can access to my website with http://example.com . But when I try to access to https://example.com , it returns ERR_HTTP2_PROTOCOL_ERROR .

Here is my package.json file:

{
  "name": "example",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "@material-ui/icons": "^4.9.1",
    "@material-ui/styles": "^4.10.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "axios": "^0.19.2",
    "bootstrap": "^4.5.0",
    "fetch": "^1.1.0",
    "history": "^5.0.0",
    "react": "^16.13.1",
    "react-bootstrap": "^1.3.0",
    "react-dom": "^16.13.1",
    "react-helmet": "^6.1.0",
    "react-notifications-component": "^2.4.0",
    "react-owl-carousel2": "^0.3.0",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1",
    "react-toast-notifications": "^2.4.0",
    "uuid": "^8.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [">0.2%", "not dead", "not op_mini all"],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "homepage": "."
}

How can I set the HTTPS protocol and make the page work?

you can install it in your ssl/tls section on cppanel (and this worked for me)

  1. Log in to cp panel
  2. Enter Username/Password
  3. Go to your Homepage
  4. Click SSL/TLS
  5. Click Install an SSL Certificate on a Domain -the domain which you want to install on.
  6. Type in your domain name
  7. Input your Certificate Files
  8. hit install
  9. reload it. -----bang ssl is installed.

you can use free ssl sites like

  1. HubSpot
  2. Let's Encrypt
  3. Comodo
  4. Cloudflare...etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM