Appengine - 部署隐藏文件夹 [英] Appengine - Deployment of hidden folder

查看:182
本文介绍了Appengine - 部署隐藏文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了验证SSL证书,我需要上传一个隐藏文件夹(/.well-known包含一些文件到我的应用程序。

应用程序与日食,但这些文件不会在应用程序接收appengine。我猜他们被过滤掉。

我试图添加隐藏文件夹作为静态文件到

 <! - 配置GWT文件的服务/缓存 -  appengine-web.xml,但它没有帮助。 > 
< static-files>
< include path =**/>
< include path =。**/>
< ; include path =**。*expiration =0s/>
< include path =**。well-knownexpiration =0s/>
< include path =**。nocache。*expiration =0s/>
< include path =**。cache。*expiration =365d/>
< include path =** .cssexpiration =30d/>
< exclude path =** .gwt.rpc/>
< /静态文件>

有什么想法可以上传这些文件夹和文件吗?

解决方案

对于像Google一样在Google App Engine中以静态方式为letsencrypt提出挑战并且失败后来到我这里的其他人,下面是为我做的:(可能实际上可以做到它是静态的,但我没有尝试它,因为我不想花费更多的时间来测试东西,伊恩显然尝试过并且无法使它工作[也许在Google App Engine内部完成的复制命令忽略了启动的目录)



取自 http://igorartamonov.com/2015/12/lets-encrypt-ssl-google-appengine/ 积分转到Igor Artamonov。

只需构建一个类似于以下内容的servlet:
$ b 公共类LetsencryptServlet扩展HttpServlet {/ b>

  public static final Map< Str ing,String> challenge = new HashMap< String,String>(); 

static {
challenges.put(RzrvZ9gd7EH3i_TsJM-B0vdEMslD4oo_lwsagGskp6c,
RzrvZ9gd7EH3i_TsJM-B0vdEMslD4oo_lwsagGskp6c.ONrZa3UelibSWEX270nTUiRZKPFXw096nENWbMGw0-E);

$ b @Override
protected void doGet(HttpServletRequest req,HttpServletResponse resp)
抛出ServletException,IOException {
if(!req.getRequestURI() .startsWith(/。well-known / acme-challenge /)){
resp.sendError(404);
return;
}
String id = req.getRequestURI()。substring(/。well-known / acme-challenge /。length());
if(!challenges.containsKey(id)){
resp.sendError(404);
return;
}
resp.setContentType(text / plain);
resp.getOutputStream()。print(challenges.get(id));
}
}

并添加到 web。 xml 类似于:

 < servlet> 
< servlet-name> letsencrypt< / servlet-name>
< servlet-class> ... LetsencryptServlet< / servlet-class>
< / servlet>
< servlet-mapping>
< servlet-name> letsencrypt< / servlet-name>
< url-pattern> /。知名/ acme-challenge / *< / url-pattern>
< / servlet-mapping>

当然,请确保servlet类具有完整的类路径以用于创建的Servlet。



该博客帖子还介绍了生成和安装证书所需的其他步骤。



Ian:你确定你正在部署servlet吗?检查日志,确保你正在测试正确的版本..也许你有一个编译问题..



干杯


To verify a SSL certificate, I need to upload a hidden folder ("/.well-known" containing some files to my application.

I am deploying java application with eclipse, but these files do not receive at the application on appengine. I guess they are filtered out.

I tried to add the hidden folder as static file to the appengine-web.xml, but it did not help.

<!-- Configure serving/caching of GWT files -->
<static-files>
    <include path="**" />
    <include path=".**" />
    <include path="**.*" expiration="0s" />
    <include path="**.well-known" expiration="0s" />
    <include path="**.nocache.*" expiration="0s" />
    <include path="**.cache.*" expiration="365d" />
    <include path="**.css" expiration="30d"/>
    <exclude path="**.gwt.rpc" />
    <exclude path="**.html" />
</static-files>

Any ideas how I could upload these folder and the files?

解决方案

For anyone else coming here like me after trying to serve the challenge for letsencrypt in a static manner in Google App Engine and failing, the following did it for me: (one might be able to actually do it statically, but I didn't try it as I didn't want to spend more time trying out stuff and Ian apparently tried that and could not make it work [maybe the copy command done internally on Google App Engine ignores the directories that start with a dot] )

Taken from http://igorartamonov.com/2015/12/lets-encrypt-ssl-google-appengine/ credits go to Igor Artamonov.

Just build a servlet like:

public class LetsencryptServlet extends HttpServlet {

    public static final Map<String, String> challenges = new HashMap<String, String>();

    static {
        challenges.put("RzrvZ9gd7EH3i_TsJM-B0vdEMslD4oo_lwsagGskp6c",
                "RzrvZ9gd7EH3i_TsJM-B0vdEMslD4oo_lwsagGskp6c.ONrZa3UelibSWEX270nTUiRZKPFXw096nENWbMGw0-E");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        if (!req.getRequestURI().startsWith("/.well-known/acme-challenge/")) {
            resp.sendError(404);
            return;
        }
        String id = req.getRequestURI().substring("/.well-known/acme-challenge/".length());
        if (!challenges.containsKey(id)) {
            resp.sendError(404);
            return;
        }
        resp.setContentType("text/plain");
        resp.getOutputStream().print(challenges.get(id));
    }
}

And add to web.xml somethine like:

<servlet>
    <servlet-name>letsencrypt</servlet-name>
    <servlet-class>...LetsencryptServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>letsencrypt</servlet-name>
    <url-pattern>/.well-known/acme-challenge/*</url-pattern>
</servlet-mapping>

Of course, be sure that the servlet class has the full classpath for your created Servlet.

That blog post also deals with the other steps necessary to generate and install the certificate.

Ian: Are you sure that you were deploying the servlet well? check the logs, make sure that you are testing the right version.. maybe you had a compilation issue..

Cheers

这篇关于Appengine - 部署隐藏文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆