L'agente distribuito Web può eseguire su una porta diversa da 80 su IIS6?
-
28-10-2019 - |
Domanda
Ho una sfida con una macchina Windows 2003 in cui devo eseguire l'agente Web Deploy su una porta che non è 80. Per impostazione predefinita, MSDEPSVC esporrà un endpoint su http: // [server]/msdeployagentservice che ovviamente ascolta implicitamente la porta 80.
Il problema che ho è che la macchina esegue anche il server SVN visivo che utilizza la porta 80 e, di conseguenza, il servizio di agente di distribuzione Web rifiuta di avviare. (Almeno questa è l'unica conclusione logica che posso trarre.) Ho una piccola app di gestione SVN sulla stessa macchina che vorrei pubblicare tramite Web Distribuzioni da cui l'enigma.
È possibile eseguire l'agente su un'altra porta? Ovviamente se questo fosse IIS7 saremmo su 8172 e tutto andrebbe bene, ma sfortunatamente non è così. Eventuali suggerimenti?
Soluzione
Ci sono un paio di modi per farlo:
Opzione 1: disinstallare e reinstallare specificando una porta diversa:
msiexec /I WebDeploy_x86_en-US.msi /passive ADDLOCAL=ALL LISTENURL=http://+:8172/MsDeployAgentService
La riga di comando installa MSDEployAgentservice e lo configura per ascoltare la porta 8172 proprio come su IIS7.
Opzione 2: riconfigurare il servizio esistente per ascoltare la porta 8172:
Fermare il MSDEPSVC (
net stop msdepsvc
)Modifica il seguente valore del registro:
HKLM\SYSTEM\CurrentControlSet\Services\MsDepSvc\Parameters\ListenUrl
Sembrerà qualcosa di simile:
http://+:80/MsDeployAgentService
Cambiare in:
http://+:8172/MsDeployAgentService
Query http ascoltatori:
httpcfg query urlacl
Dovrebbe vedere la seguente voce elencata nei risultati:
URL : http://+:80/MsDeployAgentService/ ACL : D:(A;;GX;;;NS)
Modifica ascoltatore:
httpcfg delete urlacl /u http://+:80/MsDeployAgentService/
Questo dovrebbe rispondere con:
HttpDeleteServiceConfiguration completed with 0.
httpcfg set urlacl /u http://+:8172/MsDeployAgentService/ /a D:(A;;GX;;;NS)
Questo dovrebbe rispondere con:
HttpSetServiceConfiguration completed with 0.
L'ACL specificato in
/a
L'interruttore dovrebbe corrispondere all'ACL riportato dalhttpcfg query urlacl
comandoRiavvia MSDEPSVC (
net start msdepsvc
).Puoi confermare che il servizio sta ascoltando sulla porta 8172 facendo:
netstat -an
Dovresti vedere quanto segue:
TCP 0.0.0.0:8172 0.0.0.0:0 LISTENING
Avvertimento:
Lo proverei prima su una macchina senza produzione per assicurarmi che funzioni come prevedi.
Altri suggerimenti
Queste sono le modifiche che dovevo fare per Windows 7, seguendo la ricetta di Kev:
Passaggio 3:netsh http show urlacl
Passaggio 4:netsh http delete urlacl url=http://+:80/MSDEPLOYAGENTSERVICE/
netsh http add urlacl url=http://+:8172/MSDEPLOYAGENTSERVICE/ sddl=D:(A;;GX;;;NS)
Per quello che vale, ho incollato il solido consiglio di Kev in uno script batch per fare shopping sullo shopping sul cambiamento dei numeri di porta.
:: Name: MsDepSvc.Port.cmd
:: Purpose: Modifies the TCP/IP port that the Web Deployment Agent Service
:: (MsDepSvc) listens on. Tested on Win7 Enterprise 32-bit.
:: Author: stevejansen_github@icloud.com
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:: variables
SET me=%~n0
SET url=
SET port=
IF NOT "%~1"=="" (
SET /A port=%~1
)
ECHO %me%: Web Deployment Agent Service (MsDepSvc) port change script
:: default argument values
IF "%port%"=="" (
SET /A port=8172
ECHO %me%: INFO - using default port value of 8172
)
SC.EXE query msdepsvc >NUL 2>NUL
IF NOT "%ERRORLEVEL%"=="0" (
ECHO %me%: ERROR - MsDepSvc not installed
ECHO %me%: exiting
EXIT /B 1
)
ECHO %me%: stopping MsDepSvc
NET STOP msdepsvc >NUL 2>NUL
:: check if the default port is set
REG.EXE QUERY HKLM\SYSTEM\CurrentControlSet\Services\MsDepSvc\Parameters /v ListenUrl >NUL
IF NOT "%ERRORLEVEL%"=="0" (
ECHO %me%: ERROR - MsDepSvc ListenUrl registry key not found
REG.EXE QUERY HKLM\SYSTEM\CurrentControlSet\Services\MsDepSvc\Parameters
ECHO %me%: exiting
EXIT /B 2
)
FOR /F "tokens=3" %%I IN ('REG.EXE QUERY HKLM\SYSTEM\CurrentControlSet\Services\MsDepSvc\Parameters /v ListenUrl ^| FINDSTR ListenUrl') DO (
SET url=%%I
)
ECHO %me%: INFO - MsDepSvc current reservation is "%url%"
NETSH.EXE http show urlacl "%url%" >NUL
IF NOT "%ERRORLEVEL%"=="0" (
ECHO %me%: ERROR - reservation for "%url%" not found
EXIT /B 4
)
:: save the existing urlacl properties for User, Listen, Delegate, and SDDL
FOR /F "tokens=1,* delims=: " %%A IN ('NETSH.exe http show urlacl %url% ^| FINDSTR "User Listen Delegate SDDL"') DO (
SET URLACL.%%A=%%B
)
IF NOT DEFINED URLACL.User ECHO %me%: Failed to read the exising URLACL setting for User &&GOTO :ERROR
IF NOT DEFINED URLACL.Listen ECHO %me%: Failed to read the exising URLACL setting for Listen &&GOTO :ERROR
IF NOT DEFINED URLACL.Delegate ECHO %me%: Failed to read the exising URLACL setting for Delegate &&GOTO :ERROR
IF NOT DEFINED URLACL.SDDL ECHO %me%: Failed to read the exising URLACL setting for SDDL &&GOTO :ERROR
ECHO %me%: updating MsDepSvc to listen on port %port%
REG.EXE ADD HKLM\SYSTEM\CurrentControlSet\Services\MsDepSvc\Parameters /v ListenUrl /t REG_SZ /f /d "http://+:%port%/MSDEPLOYAGENTSERVICE/"
ECHO %me%: deleting the existing reservation for MsDepSvc
NETSH.EXE http delete urlacl "%url%" || GOTO :ERROR
ECHO %me%: adding the port %port% reservation for MsDepSvc
NETSH.EXE http add urlacl url=http://+:%port%/MsDeployAgentService/ user="%URLACL.User%" listen="%URLACL.Listen%" delegate="%URLACL.Delegate%" SDDL="%URLACL.SDDL%" || GOTO :ERROR
ECHO %me%: starting MsDepSvc
NET START msdepsvc >NUL 2>NUL
ECHO %me%: process info for MsDepSvc
QUERY.EXE PROCESS MSDEPSVC.EXE
ECHO.
ECHO %me%: port bindings for MsDepSvc
NETSTAT.EXE -a -n -o | FINDSTR /R "TCP.*:%port%.*LISTENING Proto"
ECHO.
ECHO %me%: finished
:END
ENDLOCAL
ECHO ON
@EXIT /B 0
:ERROR
ECHO %me%: ERROR - exiting with errorlevel %ERRORLEVEL%
ECHO ON
@EXIT/B %ERRORLEVEL%
Leggi di più:
Vale anche la pena conoscere la magia dietro scoprire quale proprietà è memorizzata in quale chiave di registro - Enter Orca.exe - Strumento inestimabile e semplice da usare per la lettura/modifica del database MSI (cerca di non modificare).
Innanzitutto, dobbiamo trovare la proprietà nella tabella delle proprietà
Una volta trovata la proprietà, vai al tavolo del registro e trova dove viene inserita.