Skip to content

Instantly share code, notes, and snippets.

View iandmyhand's full-sized avatar
:octocat:
Doing something...

SeomGi, Han iandmyhand

:octocat:
Doing something...
View GitHub Profile
server {
...
server_name exposed.domain.com;
...
location / {
proxy_pass "http://internal.domain.com:1234";
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_redirect "http://exposed.domain.com:1234" "https://exposed.domain.com";
}
@iandmyhand
iandmyhand / nginx-subdomain-allow-origin.conf
Last active February 28, 2020 15:37
Allow cross origin list in Nginx.
set $cors "";
if ($http_origin ~ '^(https)?\:\/\/(local\.)?(dev|www)\.(domain|seconddomain)\.com')) {
# if ($http_origin ~ '^(https)?\:\/\/([\w\d\.]*){2,}(domain|seconddomain)(\.co)?\.kr') {
set $cors "true";
}
location /test {
if ($cors = "true") {
add_header Access-Control-Allow-Origin "$http_origin";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
@iandmyhand
iandmyhand / django_absolute_sum.py
Last active January 8, 2023 08:10
Django ORM function to sum absolute values.
from django.db.models import Sum
class AbsoluteSum(Sum):
name = 'AbsoluteSum'
template = '%(function)s(%(absolute)s(%(expressions)s))'
def __init__(self, expression, **extra):
super(AbsoluteSum, self).__init__(
expression, absolute='ABS ', output_field=IntegerField(), **extra)
@iandmyhand
iandmyhand / fcgi.py
Last active May 12, 2016 14:37 — forked from antoinemartin/fcgi.py
Django management command to run Django on Windows with IIS through FastCGI (for Python 3.x)
# encoding: utf-8
# FastCGI-to-WSGI bridge for files/pipes transport (not socket)
#
# Copyright (c) 2002, 2003, 2005, 2006 Allan Saddi <[email protected]>
# Copyright (c) 2011 Ruslan Keba <[email protected]>
# Copyright (c) 2012 Antoine Martin <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@iandmyhand
iandmyhand / ErrorControllerForRereadableRequestWrapper.java
Last active August 29, 2015 14:23
Handle error for RereadableRequestWrapper
@RequestMapping("/error")
@Controller
public class ErrorController {
@RequestMapping("/pageNotFound")
@ResponseBody
public Response pageNotFound() {
return new ErrorResponse(ErrorCode.NOT_FOUND_API.getCode(), ErrorCode.NOT_FOUND_API.getMessage());
}
@iandmyhand
iandmyhand / webForRereadableRequestWrapper.xml
Last active August 29, 2015 14:23
Handle error for RereadableRequestWrapper
...
<error-page>
<error-code>404</error-code>
<location>/error/pageNotFound</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error/unknownException</location>
</error-page>
@iandmyhand
iandmyhand / SomeFilterForRereadableRequestWrapper.java
Last active August 29, 2015 14:23
Apply RereadableRequestWrapper
...
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
RereadableRequestWrapper rereadableRequestWrapper = new RereadableRequestWrapper((HttpServletRequest)request);
...
chain.doFilter(rereadableRequestWrapper , response);
...
@iandmyhand
iandmyhand / RereadableRequestWrapper.java
Last active August 29, 2015 14:23
RereadableRequestWrapper
package study.hard.spring.core.commons.util
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;