• Open windows : Turn Windows Features on or Off

  • Install Node JS in server

  • Open IIS

  • Install ISNOde : https://github.com/Azure/iisnode?tab=readme-ov-file

  • Choose x64 :

    Installing for IIS 7.x/8.x

    • Install iisnode for IIS 7.x/8.x: x86 or x64 - choose bitness matching your system
    • To set up samples, from the administrative command prompt call %programfiles%\\iisnode\\setupsamples.bat
    • Go to http://localhost/node
  • Install Rewrite : https://www.iis.net/downloads/microsoft/url-rewrite

  • Open Next.js : https://nextjs.org/

  • or you cloning project nextjs in github, example :

    • git clone https://github.com/{username}/{repo}
    • cd {project name}
    • yarn or npm install
  • create server.js in route. (Sebagai Entry Poin)

    const { createServer } = require('http')
    const { parse } = require('url')
    const next = require('next')
    
    const dev = process.env.NODE_ENV !== 'production'
    const port = process.env.PORT || 3000;
    const app = next({ dev })
    const handle = app.getRequestHandler()
    
    app.prepare().then(() => {
      createServer((req, res) => {
        // Be sure to pass `true` as the second argument to `url.parse`.
        // This tells it to parse the query portion of the URL.
        const parsedUrl = parse(req.url, true)
        const { pathname, query } = parsedUrl
    
        if (pathname === '/a') {
          app.render(req, res, '/a', query)
        } else if (pathname === '/b') {
          app.render(req, res, '/b', query)
        } else {
          handle(req, res, parsedUrl)
        }
      }).listen(port, (err) => {
        if (err) throw err
        console.log(`> Ready on <http://localhost>:${port}`)
      })
    })
    
  • create web.config in route for read module in IIS

    <configuration>
      <system.webServer>    
        <rewrite>
          <rules>
            <rule name="myapp">
              <match url="/*" />
              <action type="Rewrite" url="server.js" />
            </rule>
          </rules>
        </rewrite>
    
        <iisnode node_env="production" nodeProcessCommandLine="&quot;C:\\Program Files\\nodejs\\node.exe&quot;" interceptor="&quot;%programfiles%\\iisnode\\interceptor.js&quot;" />
    		//sesuaikan path nodejs
      </system.webServer>
        <location path="" overrideMode="Deny">
            <system.webServer>
        <handlers>
          <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
        </handlers>
            </system.webServer>
        </location>
    </configuration>
    
  • Edit Package.json in scripts params :

    "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "NODE_ENV=production node server.js",
    
    "start": "nodemon server.js --exec \\"node\\" --env production",
    "lint": "next lint"
    },
    
  • npm run build (for production)

  • npm run start (local)

  • OPEN IIS

  • Create Site

    • Site name (your project)
    • physcal path is Route Folder Project next js, example : C:\laragon\www\{project}
    • Port default 80 or custom
  • choose site new project

  • click Edit Permission

    • tab security add user
    • user 1 : IUSR (ALLOW ALL PERMISSION)
    • user 2 : IIS_IUSRS (ALLOW ALL PERMISSION)
  • Restart site project

  • browse site