我购买域名:test.com
.
然后我通过执行以下操作来运行 jetty:
/opt/jetty# nohup java -jar start.jar
当我访问我的网站 ( http://test.com
) 时,它不起作用,我需要添加端口号,例如: http://test.com:8080
这很脏。所以,我想删除或隐藏这个端口号。
我尝试使用如下端口号运行 jetty:
nohup java -jar start.jar -Djetty.http.port=8080
然后,在文件 jetty-http.xml (在 /opt/jetty/etc
中),我更改了这一行:
<Set name="port"><Property name="jetty.http.port" deprecated="jetty.port" default="8080" /></Set>
我正在使用:
- 瓦丁。
- Maven。
- jetty 。
我应该在哪里管理这个?
编辑:
按照要求,这是pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>test</name>
<prerequisites>
<maven>3</maven>
</prerequisites>
<properties>
<vaadin.version>8.0.4</vaadin.version>
<vaadin.plugin.version>8.0.4</vaadin.plugin.version>
<jetty.plugin.version>9.3.9.v20160517</jetty.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jetty.port>8080</jetty.port>
<vaadin.widgetset.mode>local</vaadin.widgetset.mode>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-client-compiled</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<goal>compile-theme</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.plugin.version}</version>
<configuration>
<contextPath>/login</contextPath>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
</project>
为了防止出现问题,我尝试删除
<jetty.port>8080</jetty.port>
没有成功。
编辑:基于maven jetty plugin - remove localhost/server name from url
我尝试更改 localhost
从 /etc/hosts
到我的应用程序名称。我重新启动 jetty 。而且,它不起作用
最佳答案
如果我正确理解了这个问题,您需要使用 80 端口作为 Jetty 的端口 (jetty.http.port
),因为 http://test.com/
表示端口是默认端口 - 80。
其他引用资料:
- networking - Why was port 80 chosen as the default HTTP port and 443 as the default HTTPS port? - Super User .
- java - Change Jetty default port - Stack Overflow .
更新
这句话稍微说明了问题:
I'm sorry, I don't know how I can provide more.. I installed Jetty 9 on a debian
— Bob, the original message.
编辑/etc/default/jetty9
文件,如下所示:
# Additional arguments to pass to Jetty
JETTY_ARGS=jetty.port=80
# If you run Jetty on port numbers that are all higher than 1023, then you
# do not need authbind. It is used for binding Jetty to lower port numbers.
# (yes/no, default: no)
AUTHBIND=yes
然后,重新启动 Jetty 服务器:
# service jetty9 restart
关于java - Jetty:隐藏 URL 中的端口号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47357906/