You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js部署Azure Web App失败:端口8080无法访问求助

部署Next.js应用到Azure Web App时8080端口无响应导致启动失败

问题概述

将Next.js应用部署到Azure Web App后,网站无法正常运行。Azure日志显示容器因8080端口无HTTP响应启动失败。已尝试以下操作但均未解决问题:

  • 在Azure环境变量中指定端口8080
  • 在package.json中配置端口8080
  • 使用GitHub Actions YAML部署
  • 尝试自定义Dockerfile
  • 设置WEBSITES_PORT为8080

相关配置文件

部署YAML文件

name: Build and deploy Node.js app to Azure Web App - watkanikladen

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: '18.x'
      - name: npm install, build
        run: |
          npm install
          npm run build --if-present
      - name: Copy static files
        run: |
          cp -R ./.next/static ./.next/standalone/.next/static
      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: node-app
          path: .next/standalone
          include-hidden-files: true

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    permissions:
      id-token: write
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: node-app

      - name: Login to Azure
        uses: azure/login@v2
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}

      - name: 'Deploy to Azure Web App'
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'watkanikladen'
          slot-name: 'Production'
          package: .

package.json配置

{
"name": "testingazure",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 8080",
"build": "next build",
"start": "node_modules/next/dist/bin/next start",
"lint": "next lint"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "15.1.0"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"eslint": "^9",
"eslint-config-next": "15.1.0",
"@eslint/eslintrc": "^3"
}
}

next.config.js代码

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  output: 'standalone'
};

export default nextConfig;

错误日志

访问页面显示“Application Error”,Azure日志内容:

2024-12-15T13:09:26.313Z ERROR - Container watkanikladen_1_233bca4b for site watkanikladen has exited, failing site start
2024-12-15T13:09:26.323Z ERROR - Container watkanikladen_1_233bca4b didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.

内容的提问来源于stack exchange,提问作者Adnane Bady Soussi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 15:38:09